nus-yam/ex-repair huggingface dataset:
Program: 163223
Project: 163223
Buggy source:
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  if (activeExecution == null && !finished) {
    int length=-1;
    try {
      length=readBucket();
      if (length >= 0 && length <= 4) {
        length=readBucket();
      }
    }
 catch (    BomInput.BytesProcessedNotification e) {
      throw e;
    }
catch (    Exception e) {
      error=e;
    }
    if (length != -1) {
      activeExecution=new Thread(this,"String_Node_Str");
      activeExecution.start();
    }
 else {
      finished=true;
      try {
        buckets.put(end);
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
 finally {
        stopReading();
      }
    }
  }
  try {
    if (finished) {
      if (buckets.size() <= 1) {
        return end;
      }
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  if (activeExecution == null && !finished) {
    int length=-1;
    try {
      length=readBucket();
      if (length >= 0 && length <= 4) {
        length=readBucket();
      }
    }
 catch (    BomInput.BytesProcessedNotification e) {
      throw e;
    }
catch (    Exception e) {
      setError(e);
    }
    if (length != -1) {
      activeExecution=new Thread(this,"String_Node_Str");
      activeExecution.start();
    }
 else {
      finished=true;
      try {
        buckets.put(end);
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
 finally {
        stopReading();
      }
    }
  }
  try {
    if (finished) {
      if (buckets.size() <= 1) {
        return end;
      }
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}
Program: 163224
Project: 163224
Buggy source:
/** 
 * The   {@link CharBucket} loading process that executes in parallel until the input is completely read.Once the end of the input is reached, the  {@link java.io.Reader} instance provided in the constructor is closed.
 */
@Override public void run(){
  try {
    try {
      while (readBucket() != -1 && active)       ;
    }
  finally {
      buckets.put(end);
    }
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  Exception e) {
    finished=true;
    error=e;
  }
 finally {
    stopReading();
  }
}

Fixed version (ground truth):
/** 
 * The   {@link CharBucket} loading process that executes in parallel until the input is completely read.Once the end of the input is reached, the  {@link java.io.Reader} instance provided in the constructor is closed.
 */
@Override public void run(){
  try {
    try {
      while (active && readBucket() != -1)       ;
    }
  finally {
      buckets.put(end);
    }
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  Exception e) {
    finished=true;
    setError(e);
  }
 finally {
    stopReading();
  }
}
Program: 163226
Project: 163226
Buggy source:
private String[] handleEOF(){
  String[] row=null;
  try {
    boolean consumeValueOnEOF=consumeValueOnEOF();
    if (output.column != 0 || consumeValueOnEOF) {
      if (output.appender.length() > 0 || consumeValueOnEOF) {
        output.valueParsed();
      }
 else {
        output.emptyParsed();
      }
      row=output.rowParsed();
    }
 else     if (output.appender.length() > 0) {
      output.valueParsed();
      row=output.rowParsed();
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw handleException(e);
  }
  if (row != null && processor != NoopProcessor.instance) {
    rowProcessed(row);
  }
  return row;
}

Fixed version (ground truth):
private String[] handleEOF(){
  String[] row=null;
  try {
    boolean consumeValueOnEOF=consumeValueOnEOF();
    if (output.column != 0 || consumeValueOnEOF) {
      if (output.appender.length() > 0 || consumeValueOnEOF) {
        output.valueParsed();
      }
 else {
        output.emptyParsed();
      }
      row=output.rowParsed();
    }
 else     if (output.appender.length() > 0) {
      output.valueParsed();
      row=output.rowParsed();
    }
  }
 catch (  Throwable e) {
    throw handleException(e);
  }
  if (row != null && processor != NoopProcessor.instance) {
    rowProcessed(row);
  }
  return row;
}
Program: 163227
Project: 163227
Buggy source:
@Test(expectedExceptions=ArrayIndexOutOfBoundsException.class) public void test100Cols() throws Exception {
  final CsvParserSettings s=new CsvParserSettings();
  s.setHeaderExtractionEnabled(true);
  s.setMaxColumns(99);
  final RowListProcessor rowListProcessor=new RowListProcessor();
  s.setProcessor(rowListProcessor);
  final CsvParser parser=new CsvParser(s);
  parser.parse(newReader("String_Node_Str"));
  fail("String_Node_Str");
}

Fixed version (ground truth):
@Test(expectedExceptions=TextParsingException.class) public void test100Cols() throws Exception {
  final CsvParserSettings s=new CsvParserSettings();
  s.setHeaderExtractionEnabled(true);
  s.setMaxColumns(99);
  s.setLineSeparatorDetectionEnabled(true);
  final RowListProcessor rowListProcessor=new RowListProcessor();
  s.setProcessor(rowListProcessor);
  final CsvParser parser=new CsvParser(s);
  parser.parse(newReader("String_Node_Str"));
  fail("String_Node_Str");
}
Program: 163229
Project: 163229
Buggy source:
/** 
 * Converts the given parsed row to a   {@link Record}
 * @return a {@link Record} representing the given row.
 */
Record toRecord(String[] row);

Fixed version (ground truth):
/** 
 * Converts the given parsed row to a   {@link Record}
 * @param row the row to be converted into a {@link Record}
 * @return a {@link Record} representing the given row.
 */
Record toRecord(String[] row);
Program: 163230
Project: 163230
Buggy source:
/** 
 * Unsupported operation.
 * @param input the input be converted.
 * @return throws a {@code UnsupportedOperationException}
 * @throws UnsupportedOperationException
 */
@Override public Object revert(String input){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Unsupported operation.
 * @param input the input be converted.
 * @return throws a {@code UnsupportedOperationException}
 */
@Override public Object revert(String input){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 163231
Project: 163231
Buggy source:
/** 
 * Defines whether or not leading whitespaces from quoted values should be skipped  (defaults to false) Note: if   {@link #keepQuotes} evaluates to {@code true}, values won't be trimmed.
 * @param ignoreLeadingWhitespaces whether leading whitespaces from quoted values should be skipped
 */
public void setIgnoreLeadingWhitespacesInQuotes(boolean ignoreLeadingWhitespacesInQuotes){
  this.ignoreLeadingWhitespacesInQuotes=ignoreLeadingWhitespacesInQuotes;
}

Fixed version (ground truth):
/** 
 * Defines whether or not leading whitespaces from quoted values should be skipped  (defaults to false) Note: if   {@link #keepQuotes} evaluates to {@code true}, values won't be trimmed.
 * @param ignoreLeadingWhitespacesInQuotes whether leading whitespaces from quoted values should be skipped
 */
public void setIgnoreLeadingWhitespacesInQuotes(boolean ignoreLeadingWhitespacesInQuotes){
  this.ignoreLeadingWhitespacesInQuotes=ignoreLeadingWhitespacesInQuotes;
}
Program: 163232
Project: 163232
Buggy source:
/** 
 * Returns the name to be used as a header based on a given field and its   {@link Parsed} annotation.
 * @return the header name to be used for the given field.
 */
public String getHeaderName(){
  if (target == null) {
    return null;
  }
  String name=null;
  Parsed annotation=findAnnotation(target,Parsed.class);
  if (annotation != null) {
    if (annotation.field().length == 0) {
      name=getTargetName();
    }
 else {
      name=annotation.field()[0];
    }
  }
  if (transformer != null) {
    if (field != null) {
      return transformer.transformName(field,name);
    }
 else {
      return transformer.transformName(method,name);
    }
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name to be used as a header based on a given field and its   {@link Parsed} annotation.
 * @return the header name to be used for the given field.
 */
public String getHeaderName(){
  if (target == null) {
    return null;
  }
  String name=null;
  Parsed annotation=findAnnotation(target,Parsed.class);
  if (annotation != null) {
    if (annotation.field().length == 0) {
      name=getTargetName();
    }
 else {
      name=annotation.field()[0];
    }
    if (name.length() == 0) {
      name=getTargetName();
    }
  }
  if (transformer != null) {
    if (field != null) {
      return transformer.transformName(field,name);
    }
 else {
      return transformer.transformName(method,name);
    }
  }
  return name;
}
Program: 163233
Project: 163233
Buggy source:
/** 
 * Requests the next batch of characters from the implementing class and updates the character count. <p> If there are no more characters in the input, the reading will stop by invoking the   {@link AbstractCharInputReader#stop()} method.
 */
private void updateBuffer(){
  if (length - recordStart > 0 && buffer != null && !skipping) {
    tmp.append(buffer,recordStart,length - recordStart);
  }
  recordStart=0;
  reloadBuffer();
  charCount+=i;
  i=0;
  if (length == -1) {
    stop();
    incrementLineCount=true;
  }
  if (inputAnalysisProcesses != null) {
    try {
      for (      InputAnalysisProcess process : inputAnalysisProcesses) {
        process.execute(buffer,length);
      }
    }
  finally {
      if (length > 4) {
        inputAnalysisProcesses=null;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Requests the next batch of characters from the implementing class and updates the character count. <p> If there are no more characters in the input, the reading will stop by invoking the   {@link AbstractCharInputReader#stop()} method.
 */
private void updateBuffer(){
  if (length - recordStart > 0 && buffer != null && !skipping) {
    tmp.append(buffer,recordStart,length - recordStart);
  }
  recordStart=0;
  reloadBuffer();
  charCount+=i;
  i=0;
  if (length == -1) {
    stop();
    incrementLineCount=true;
  }
  if (inputAnalysisProcesses != null) {
    if (length > 0 && length <= 4) {
      int tmpLength=length;
      char[] tmp=Arrays.copyOfRange(buffer,0,length + 1);
      List<InputAnalysisProcess> processes=inputAnalysisProcesses;
      inputAnalysisProcesses=null;
      reloadBuffer();
      inputAnalysisProcesses=processes;
      if (length != -1) {
        char[] newBuffer=new char[tmpLength + buffer.length];
        System.arraycopy(tmp,0,newBuffer,0,tmpLength);
        System.arraycopy(buffer,0,newBuffer,tmpLength,length);
        buffer=newBuffer;
        length+=tmpLength;
      }
 else {
        buffer=tmp;
        length=tmpLength;
      }
    }
    try {
      for (      InputAnalysisProcess process : inputAnalysisProcesses) {
        process.execute(buffer,length);
      }
    }
  finally {
      if (length > 4) {
        inputAnalysisProcesses=null;
      }
    }
  }
}
Program: 163235
Project: 163235
Buggy source:
/** 
 * Configures the parser based on the annotations provided in a given class
 * @param beanClass the classes whose annotations will be processed to derive configurations for parsing
 */
protected synchronized void configureFromAnnotations(Class<?> beanClass){
  Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
  String[] headersFromBean=ArgumentUtils.EMPTY_STRING_ARRAY;
  boolean allFieldsIndexBased=AnnotationHelper.allFieldsIndexBasedForParsing(beanClass);
  boolean extractHeaders=!allFieldsIndexBased;
  if (headerAnnotation != null) {
    if (headerAnnotation.sequence().length > 0) {
      headersFromBean=headerAnnotation.sequence();
    }
    extractHeaders=headerAnnotation.extract();
  }
  if (headerExtractionEnabled == null) {
    setHeaderExtractionEnabled(extractHeaders);
  }
  if (getHeaders() == null && headersFromBean.length > 0 && !headerExtractionEnabled) {
    setHeaders(headersFromBean);
  }
  if (getFieldSet() == null) {
    if (allFieldsIndexBased) {
      selectIndexes(AnnotationHelper.getSelectedIndexes(beanClass,MethodFilter.ONLY_SETTERS));
    }
 else     if (headersFromBean.length > 0 && AnnotationHelper.allFieldsNameBasedForParsing(beanClass)) {
      selectFields(headersFromBean);
    }
  }
}

Fixed version (ground truth):
/** 
 * Configures the parser based on the annotations provided in a given class
 * @param beanClass the classes whose annotations will be processed to derive configurations for parsing
 */
protected synchronized void configureFromAnnotations(Class<?> beanClass){
  if (!deriveHeadersFrom(beanClass)) {
    return;
  }
  Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
  String[] headersFromBean=ArgumentUtils.EMPTY_STRING_ARRAY;
  boolean allFieldsIndexBased=AnnotationHelper.allFieldsIndexBasedForParsing(beanClass);
  boolean extractHeaders=!allFieldsIndexBased;
  if (headerAnnotation != null) {
    if (headerAnnotation.sequence().length > 0) {
      headersFromBean=headerAnnotation.sequence();
    }
    extractHeaders=headerAnnotation.extract();
  }
  if (headerExtractionEnabled == null) {
    setHeaderExtractionEnabled(extractHeaders);
  }
  if (getHeaders() == null && headersFromBean.length > 0 && !headerExtractionEnabled) {
    setHeadersDerivedFromClass(beanClass,headersFromBean);
  }
  if (getFieldSet() == null) {
    if (allFieldsIndexBased) {
      selectIndexes(AnnotationHelper.getSelectedIndexes(beanClass,MethodFilter.ONLY_SETTERS));
    }
 else     if (headersFromBean.length > 0 && AnnotationHelper.allFieldsNameBasedForParsing(beanClass)) {
      selectFields(headersFromBean);
    }
  }
}
Program: 163236
Project: 163236
Buggy source:
/** 
 * Configures the writer based on the annotations provided in a given class
 * @param beanClass the classes whose annotations will be processed to derive configurations for writing.
 */
protected void configureFromAnnotations(Class<?> beanClass){
  Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
  String[] headersFromBean=AnnotationHelper.deriveHeaderNamesFromFields(beanClass,MethodFilter.ONLY_GETTERS);
  boolean writeHeaders=false;
  if (headerAnnotation != null) {
    if (headerAnnotation.sequence().length > 0) {
      headersFromBean=headerAnnotation.sequence();
    }
    writeHeaders=headerAnnotation.write();
  }
  if (headerWritingEnabled == null) {
    headerWritingEnabled=writeHeaders;
  }
  if (getHeaders() == null && headersFromBean.length > 0) {
    setHeaders(headersFromBean);
  }
}

Fixed version (ground truth):
/** 
 * Configures the writer based on the annotations provided in a given class
 * @param beanClass the classes whose annotations will be processed to derive configurations for writing.
 */
protected void configureFromAnnotations(Class<?> beanClass){
  if (!deriveHeadersFrom(beanClass)) {
    return;
  }
  Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
  String[] headersFromBean=AnnotationHelper.deriveHeaderNamesFromFields(beanClass,MethodFilter.ONLY_GETTERS);
  boolean writeHeaders=false;
  if (headerAnnotation != null) {
    if (headerAnnotation.sequence().length > 0) {
      headersFromBean=headerAnnotation.sequence();
    }
    writeHeaders=headerAnnotation.write();
  }
  if (headerWritingEnabled == null) {
    headerWritingEnabled=writeHeaders;
  }
  if (getHeaders() == null && headersFromBean.length > 0) {
    setHeadersDerivedFromClass(beanClass,headersFromBean);
  }
}
Program: 163238
Project: 163238
Buggy source:
/** 
 * Removes leading and trailing white spaces from the input and returns the result. Equivalent to   {@link TrimConversion#revert(String)}
 * @param input the String to be trimmed
 * @return the input String without leading and trailing white spaces, or null if the input is null.
 */
@Override public String execute(String input){
  if (input == null) {
    return null;
  }
  if (length != -1) {
    input=input.trim();
    if (input.length() > length) {
      return input.substring(0,length);
    }
  }
  return input.trim();
}

Fixed version (ground truth):
/** 
 * Removes leading and trailing white spaces from the input and returns the result. Equivalent to   {@link TrimConversion#revert(String)}
 * @param input the String to be trimmed
 * @return the input String without leading and trailing white spaces, or null if the input is null.
 */
@Override public String execute(String input){
  if (input == null) {
    return null;
  }
  if (length != -1) {
    int begin=0;
    while (input.charAt(begin) <= ' ') {
      begin++;
    }
    int end=begin + (length < input.length() ? length : input.length()) - 1;
    if (end >= input.length()) {
      end=input.length() - 1;
    }
    while (input.charAt(end) <= ' ') {
      end--;
    }
    return input.substring(begin,end + 1);
  }
  return input.trim();
}
Program: 163240
Project: 163240
Buggy source:
private RowProcessor createWritingRowProcessor(final Writer output){
  return new RowProcessor(){
    private AbstractWriter<W> writer;
    @Override public void processStarted(    ParsingContext context){
      writer=createWriter(output,writerSettings);
    }
    @Override public void rowProcessed(    String[] row,    ParsingContext context){
      writer.writeRow(row);
    }
    @Override public void processEnded(    ParsingContext context){
      if (!keepResourcesOpen) {
        writer.close();
      }
    }
  }
;
}

Fixed version (ground truth):
private RowProcessor createWritingRowProcessor(final Writer output){
  return new RowProcessor(){
    private AbstractWriter<W> writer;
    @Override public void processStarted(    ParsingContext context){
      writer=createWriter(output,writerSettings);
    }
    @Override public void rowProcessed(    String[] row,    ParsingContext context){
      writer.writeRow(row);
    }
    @Override public void processEnded(    ParsingContext context){
      close(writer);
    }
  }
;
}
Program: 163241
Project: 163241
Buggy source:
void run(ResultSet rs) throws Exception {
  StringWriter output=new StringWriter();
  routineImpl.setKeepResourcesOpen(true);
  routineImpl.write(rs,output);
  output.write("String_Node_Str");
  assertFalse(rs.isClosed());
  output.close();
  result=output.toString();
  rs.close();
}

Fixed version (ground truth):
public void run(ResultSet rs){
  CsvWriterSettings settings=new CsvWriterSettings();
  CsvRoutines csvRoutines=new CsvRoutines(settings);
  csvRoutines.setKeepResourcesOpen(true);
  FileOutputStream fout=null;
  try {
    try {
      fout=new FileOutputStream(tmp);
      csvRoutines.write(rs,fout);
    }
  finally {
      fout.close();
    }
  }
 catch (  Exception e) {
    throw new IllegalStateException(e);
  }
}
Program: 163242
Project: 163242
Buggy source:
/** 
 * Stops parsing and closes all open resources.
 */
public final void stopParsing(){
  try {
    try {
      context.stop();
    }
  finally {
      try {
        processor.processEnded(context);
      }
  finally {
        output.appender.reset();
        input.stop();
      }
    }
  }
 catch (  Throwable error) {
    throw handleException(error);
  }
}

Fixed version (ground truth):
/** 
 * Stops parsing and closes all open resources.
 */
public final void stopParsing(){
  try {
    try {
      if (context != null) {
        context.stop();
      }
    }
  finally {
      try {
        if (processor != null) {
          processor.processEnded(context);
        }
      }
  finally {
        if (output != null) {
          output.appender.reset();
        }
        if (input != null) {
          input.stop();
        }
      }
    }
  }
 catch (  Throwable error) {
    throw handleException(error);
  }
}
Program: 163243
Project: 163243
Buggy source:
protected void setContext(Context context){
  if (context instanceof ParsingContext) {
    setParsingContext((ParsingContext)context);
  }
 else {
    setParsingContext(null);
  }
  this.columnIndex=context == null ? -1 : context.currentColumn();
  this.recordNumber=context == null ? -1L : context.currentRecord();
  if (this.headers == null) {
    this.headers=context == null ? null : context.headers();
  }
  this.extractedIndexes=context == null ? null : context.extractedFieldIndexes();
}

Fixed version (ground truth):
protected void setContext(Context context){
  if (context != null) {
    if (context instanceof ParsingContext) {
      setParsingContext((ParsingContext)context);
    }
 else {
      setParsingContext(null);
    }
    this.columnIndex=context == null ? -1 : context.currentColumn();
    this.recordNumber=context == null ? -1L : context.currentRecord();
    if (this.headers == null) {
      this.headers=context == null ? null : context.headers();
    }
    this.extractedIndexes=context == null ? null : context.extractedFieldIndexes();
  }
}
Program: 163245
Project: 163245
Buggy source:
/** 
 * An implementation of   {@link CharInputReader} which loads the parser buffer in parallel or sequentially, as defined by the readInputOnSeparateThread property
 * @param whitespaceRangeStart starting range of characters considered to be whitespace.
 * @return The input reader as chosen with the readInputOnSeparateThread property.
 */
CharInputReader newCharInputReader(int whitespaceRangeStart){
  if (readInputOnSeparateThread) {
    if (lineSeparatorDetectionEnabled) {
      return new ConcurrentCharInputReader(getFormat().getNormalizedNewline(),this.getInputBufferSize(),10,whitespaceRangeStart);
    }
 else {
      return new ConcurrentCharInputReader(getFormat().getLineSeparator(),getFormat().getNormalizedNewline(),this.getInputBufferSize(),10,whitespaceRangeStart);
    }
  }
 else {
    if (lineSeparatorDetectionEnabled) {
      return new DefaultCharInputReader(getFormat().getNormalizedNewline(),this.getInputBufferSize(),whitespaceRangeStart);
    }
 else {
      return new DefaultCharInputReader(getFormat().getLineSeparator(),getFormat().getNormalizedNewline(),this.getInputBufferSize(),whitespaceRangeStart);
    }
  }
}

Fixed version (ground truth):
/** 
 * An implementation of   {@link CharInputReader} which loads the parser buffer in parallel or sequentially, as defined by the readInputOnSeparateThread property
 * @param whitespaceRangeStart starting range of characters considered to be whitespace.
 * @return The input reader as chosen with the readInputOnSeparateThread property.
 */
protected CharInputReader newCharInputReader(int whitespaceRangeStart){
  if (readInputOnSeparateThread) {
    if (lineSeparatorDetectionEnabled) {
      return new ConcurrentCharInputReader(getFormat().getNormalizedNewline(),this.getInputBufferSize(),10,whitespaceRangeStart);
    }
 else {
      return new ConcurrentCharInputReader(getFormat().getLineSeparator(),getFormat().getNormalizedNewline(),this.getInputBufferSize(),10,whitespaceRangeStart);
    }
  }
 else {
    if (lineSeparatorDetectionEnabled) {
      return new DefaultCharInputReader(getFormat().getNormalizedNewline(),this.getInputBufferSize(),whitespaceRangeStart);
    }
 else {
      return new DefaultCharInputReader(getFormat().getLineSeparator(),getFormat().getNormalizedNewline(),this.getInputBufferSize(),whitespaceRangeStart);
    }
  }
}
Program: 163246
Project: 163246
Buggy source:
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  try {
    if (finished) {
      return end;
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  try {
    if (finished) {
      if (buckets.size() <= 1) {
        return end;
      }
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}
Program: 163247
Project: 163247
Buggy source:
/** 
 * Stops the CharInputReader from reading characters from the   {@link java.io.Reader} provided in {@link ConcurrentCharInputReader#start(Reader)} and closes it.Also stops the input reading thread.
 */
@Override public void stop(){
  if (bucketLoader != null) {
    bucketLoader.stopReading();
    bucketLoader.reportError();
    if (bucketLoader.notification != null) {
      BomInput.BytesProcessedNotification notification=bucketLoader.notification;
      bucketLoader=null;
      unwrapInputStream(notification);
    }
  }
}

Fixed version (ground truth):
/** 
 * Stops the CharInputReader from reading characters from the   {@link java.io.Reader} provided in {@link ConcurrentCharInputReader#start(Reader)} and closes it.Also stops the input reading thread.
 */
@Override public void stop(){
  if (!unwrapping && bucketLoader != null) {
    bucketLoader.stopReading();
    bucketLoader.reportError();
  }
}
Program: 163248
Project: 163248
Buggy source:
/** 
 * Starts an input reading thread to load characters from the given reader into "buckets" of characters
 */
@Override protected void setReader(Reader reader){
  stop();
  bucketLoader=new ConcurrentCharLoader(reader,bucketSize,bucketQuantity);
  bucketLoader.reportError();
}

Fixed version (ground truth):
/** 
 * Starts an input reading thread to load characters from the given reader into "buckets" of characters
 */
@Override protected void setReader(Reader reader){
  if (!unwrapping) {
    stop();
    bucketLoader=new ConcurrentCharLoader(reader,bucketSize,bucketQuantity);
    bucketLoader.reportError();
  }
 else {
    bucketLoader.reader=reader;
  }
  unwrapping=false;
}
Program: 163249
Project: 163249
Buggy source:
/** 
 * Assigns the next "bucket" of characters to the   {@link ConcurrentCharInputReader#buffer} attribute, and updates the {@link ConcurrentCharInputReader#length} to the number of characters read.
 */
@Override protected void reloadBuffer(){
  CharBucket currentBucket=bucketLoader.nextBucket();
  bucketLoader.reportError();
  super.buffer=currentBucket.data;
  super.length=currentBucket.length;
}

Fixed version (ground truth):
/** 
 * Assigns the next "bucket" of characters to the   {@link ConcurrentCharInputReader#buffer} attribute, and updates the {@link ConcurrentCharInputReader#length} to the number of characters read.
 */
@Override protected void reloadBuffer(){
  try {
    CharBucket currentBucket=bucketLoader.nextBucket();
    bucketLoader.reportError();
    super.buffer=currentBucket.data;
    super.length=currentBucket.length;
  }
 catch (  BomInput.BytesProcessedNotification e) {
    unwrapping=true;
    unwrapInputStream(e);
  }
}
Program: 163250
Project: 163250
Buggy source:
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  try {
    if (finished) {
      if (buckets.size() <= 1) {
        return end;
      }
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next available bucket. Blocks until a bucket is made available or the reading process stops.
 * @return the next available bucket.
 */
@SuppressWarnings("String_Node_Str") public synchronized CharBucket nextBucket(){
  if (activeExecution == null && !finished) {
    int length=-1;
    try {
      length=readBucket();
      if (length >= 0 && length <= 4) {
        length=readBucket();
      }
    }
 catch (    BomInput.BytesProcessedNotification e) {
      throw e;
    }
catch (    Exception e) {
      error=e;
    }
    if (length != -1) {
      activeExecution=new Thread(this,"String_Node_Str");
      activeExecution.start();
    }
 else {
      finished=true;
      try {
        buckets.put(end);
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
 finally {
        stopReading();
      }
    }
  }
  try {
    if (finished) {
      if (buckets.size() <= 1) {
        return end;
      }
    }
    if (currentBucket != null) {
      instances.release(currentBucket);
    }
    Object element=buckets.take();
    if (element == end) {
      finished=true;
      return end;
    }
 else {
      currentBucket=(Entry<CharBucket>)element;
    }
    return currentBucket.get();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
    finished=true;
    return end;
  }
}
Program: 163251
Project: 163251
Buggy source:
/** 
 * The   {@link CharBucket} loading process that executes in parallel until the input is completely read.Once the end of the input is reached, the  {@link java.io.Reader} instance provided in the constructor is closed.
 */
@Override public void run(){
  Thread.currentThread().setName("String_Node_Str");
  try {
    try {
      int length;
      do {
        Entry<CharBucket> bucket=instances.allocate();
        length=bucket.get().fill(reader);
        if (length != -1) {
          buckets.put(bucket);
        }
 else {
          instances.release(bucket);
        }
      }
 while (active && length != -1);
    }
  finally {
      buckets.put(end);
    }
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  BomInput.BytesProcessedNotification e) {
    finished=true;
    notification=e;
  }
catch (  Exception e) {
    finished=true;
    error=e;
  }
 finally {
    stopReading();
  }
}

Fixed version (ground truth):
/** 
 * The   {@link CharBucket} loading process that executes in parallel until the input is completely read.Once the end of the input is reached, the  {@link java.io.Reader} instance provided in the constructor is closed.
 */
@Override public void run(){
  try {
    try {
      while (readBucket() != -1 && active)       ;
    }
  finally {
      buckets.put(end);
    }
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  Exception e) {
    finished=true;
    error=e;
  }
 finally {
    stopReading();
  }
}
Program: 163252
Project: 163252
Buggy source:
/** 
 * Stops the   {@link CharBucket} loading process and closes the reader provided in the constructor of this class
 */
public void stopReading(){
  active=false;
  try {
    reader.close();
  }
 catch (  IOException e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
 finally {
    try {
      activeExecution.interrupt();
    }
 catch (    Throwable ex) {
      throw new IllegalStateException("String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Stops the   {@link CharBucket} loading process and closes the reader provided in the constructor of this class
 */
public void stopReading(){
  active=false;
  try {
    reader.close();
  }
 catch (  IOException e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
 finally {
    try {
      if (activeExecution != null) {
        activeExecution.interrupt();
      }
    }
 catch (    Throwable ex) {
      throw new IllegalStateException("String_Node_Str",ex);
    }
  }
}
Program: 163253
Project: 163253
Buggy source:
/** 
 * Creates a   {@link FixedInstancePool} with a given amount of {@link CharBucket} instances and starts a thread to fill each one.
 * @param reader         The source of characters to extract and fill {@link CharBucket} instances
 * @param bucketSize     The size of each individual {@link CharBucket}
 * @param bucketQuantity The number of {@link CharBucket} instances used to extract characters from the given reader.
 */
public ConcurrentCharLoader(Reader reader,final int bucketSize,int bucketQuantity){
  this.end=new CharBucket(-1);
  this.buckets=new ArrayBlockingQueue<Object>(bucketQuantity);
  this.reader=reader;
  this.instances=new FixedInstancePool<CharBucket>(bucketQuantity){
    @Override protected CharBucket newInstance(){
      return new CharBucket(bucketSize);
    }
  }
;
  finished=false;
  active=true;
  activeExecution=new Thread(this,"String_Node_Str");
  activeExecution.start();
}

Fixed version (ground truth):
/** 
 * Creates a   {@link FixedInstancePool} with a given amount of {@link CharBucket} instances and starts a thread to fill each one.
 * @param reader         The source of characters to extract and fill {@link CharBucket} instances
 * @param bucketSize     The size of each individual {@link CharBucket}
 * @param bucketQuantity The number of {@link CharBucket} instances used to extract characters from the given reader.
 */
public ConcurrentCharLoader(Reader reader,final int bucketSize,int bucketQuantity){
  this.end=new CharBucket(-1);
  this.buckets=new ArrayBlockingQueue<Object>(bucketQuantity);
  this.reader=reader;
  this.instances=new FixedInstancePool<CharBucket>(bucketQuantity){
    @Override protected CharBucket newInstance(){
      return new CharBucket(bucketSize);
    }
  }
;
  finished=false;
  active=true;
}
Program: 163254
Project: 163254
Buggy source:
@Override public final void skipLines(long lines){
  if (lines < 1) {
    return;
  }
  long expectedLineCount=this.lineCount + lines;
  try {
    do {
      nextChar();
    }
 while (lineCount < expectedLineCount);
    if (lineCount < lines) {
      throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
    }
  }
 catch (  EOFException ex) {
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public final void skipLines(long lines){
  if (lines < 1) {
    skipping=false;
    return;
  }
  skipping=true;
  long expectedLineCount=this.lineCount + lines;
  try {
    do {
      nextChar();
    }
 while (lineCount < expectedLineCount);
    skipping=false;
    if (lineCount < lines) {
      throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
    }
  }
 catch (  EOFException ex) {
    skipping=false;
    throw new IllegalArgumentException("String_Node_Str" + lines + "String_Node_Str"+ (expectedLineCount - lines)+ "String_Node_Str");
  }
}
Program: 163255
Project: 163255
Buggy source:
/** 
 * Requests the next batch of characters from the implementing class and updates the character count. <p> If there are no more characters in the input, the reading will stop by invoking the   {@link AbstractCharInputReader#stop()} method.
 */
private void updateBuffer(){
  if (length - recordStart > 0 && buffer != null) {
    tmp.append(buffer,recordStart,length - recordStart);
  }
  recordStart=0;
  reloadBuffer();
  charCount+=i;
  i=0;
  if (length == -1) {
    stop();
    incrementLineCount=true;
  }
  if (inputAnalysisProcesses != null) {
    try {
      for (      InputAnalysisProcess process : inputAnalysisProcesses) {
        process.execute(buffer,length);
      }
    }
  finally {
      if (length > 4) {
        inputAnalysisProcesses=null;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Requests the next batch of characters from the implementing class and updates the character count. <p> If there are no more characters in the input, the reading will stop by invoking the   {@link AbstractCharInputReader#stop()} method.
 */
private void updateBuffer(){
  if (length - recordStart > 0 && buffer != null && !skipping) {
    tmp.append(buffer,recordStart,length - recordStart);
  }
  recordStart=0;
  reloadBuffer();
  charCount+=i;
  i=0;
  if (length == -1) {
    stop();
    incrementLineCount=true;
  }
  if (inputAnalysisProcesses != null) {
    try {
      for (      InputAnalysisProcess process : inputAnalysisProcesses) {
        process.execute(buffer,length);
      }
    }
  finally {
      if (length > 4) {
        inputAnalysisProcesses=null;
      }
    }
  }
}
Program: 163256
Project: 163256
Buggy source:
/** 
 * Writes a collection of annotated java beans to a given output.
 * @param elements the elements to write to the output
 * @param beanType the type of element in the given collection
 * @param output   the output into which the given elements will be written
 * @param headers  headers to use in the first row of the written result.
 * @param < T >      the type of element in the given collection
 */
public <T>void writeAll(Iterable<T> elements,Class<T> beanType,Writer output,String... headers){
  setRowWriterProcessor(new BeanWriterProcessor<T>(beanType));
  try {
    if (headers.length > 0) {
      writerSettings.setHeaders(headers);
      writerSettings.setHeaderWritingEnabled(true);
    }
    createWriter(output,writerSettings).processRecordsAndClose(elements);
  }
  finally {
    writerSettings.setRowWriterProcessor(null);
  }
}

Fixed version (ground truth):
/** 
 * Writes a collection of annotated java beans to a given output.
 * @param elements the elements to write to the output
 * @param beanType the type of element in the given collection
 * @param output   the output into which the given elements will be written
 * @param headers  headers to use in the first row of the written result.
 * @param < T >      the type of element in the given collection
 */
public <T>void writeAll(Iterable<T> elements,Class<T> beanType,Writer output,String... headers){
  setRowWriterProcessor(new BeanWriterProcessor<T>(beanType));
  try {
    if (headers.length > 0) {
      writerSettings.setHeaders(headers);
      writerSettings.setHeaderWritingEnabled(true);
    }
    if (keepResourcesOpen && previousOutput == output) {
      writerSettings.setHeaderWritingEnabled(false);
    }
    AbstractWriter<W> writer=createWriter(output,writerSettings);
    if (keepResourcesOpen) {
      writer.processRecords(elements);
      previousOutput=output;
    }
 else {
      writer.processRecordsAndClose(elements);
    }
  }
  finally {
    writerSettings.setRowWriterProcessor(null);
  }
}
Program: 163257
Project: 163257
Buggy source:
/** 
 * Returns the parser configuration (if any) used by the routines of this utility class.
 * @return the parser configuration.
 */
public final P getParserSettings(){
  return parserSettings;
}

Fixed version (ground truth):
/** 
 * Returns the parser configuration (if any) used by the routines of this utility class.
 * @return the parser configuration.
 */
public final P getParserSettings(){
  validateParserSettings();
  return parserSettings;
}
Program: 163258
Project: 163258
Buggy source:
/** 
 * Returns the writer configuration (if any) used by the routines of this utility class.
 * @return the writer configuration.
 */
public final W getWriterSettings(){
  return writerSettings;
}

Fixed version (ground truth):
/** 
 * Returns the writer configuration (if any) used by the routines of this utility class.
 * @return the writer configuration.
 */
public final W getWriterSettings(){
  validateWriterSettings();
  return writerSettings;
}
Program: 163261
Project: 163261
Buggy source:
@Override protected final boolean consumeValueOnEOF(){
  if (ch == quote) {
    if (prev == quote) {
      if (keepQuotes) {
        output.appender.append(quote);
      }
      return true;
    }
 else {
      output.appender.append(quote);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override protected final boolean consumeValueOnEOF(){
  if (ch == quote) {
    if (prev == quote) {
      if (keepQuotes) {
        output.appender.append(quote);
      }
      return true;
    }
 else {
      if (!unescaped) {
        output.appender.append(quote);
      }
    }
  }
  return false;
}
Program: 163262
Project: 163262
Buggy source:
protected final void unwrapInputStream(BomInput.BytesProcessedNotification notification){
  InputStream inputStream=notification.input;
  String encoding=notification.encoding;
  if (encoding != null) {
    try {
      start(new InputStreamReader(inputStream,encoding));
    }
 catch (    Exception e) {
      throw new IllegalStateException(e);
    }
  }
 else {
    start(new InputStreamReader(inputStream));
  }
}

Fixed version (ground truth):
protected final void unwrapInputStream(BomInput.BytesProcessedNotification notification){
  InputStream inputStream=notification.input;
  String encoding=notification.encoding;
  if (encoding != null) {
    try {
      start(new InputStreamReader(inputStream,encoding));
    }
 catch (    Exception e) {
      throw new IllegalStateException(e);
    }
  }
 else {
    length=-1;
    start(new InputStreamReader(inputStream));
  }
}
Program: 163263
Project: 163263
Buggy source:
@Override public T next(){
  T out=(T)beanHolder[0];
  if (parser.parseNext() == null) {
    beanHolder[0]=null;
  }
  return out;
}

Fixed version (ground truth):
@Override public T next(){
  if (hasNext()) {
    T out=(T)beanHolder[0];
    beanHolder[0]=null;
    return out;
  }
  return null;
}
Program: 163264
Project: 163264
Buggy source:
@Override public ResultIterator<T,ParsingContext> iterator(){
  final AbstractParser<P> parser=createParser(parserSettings);
  parser.beginParsing(input);
  context=parser.getContext();
  parser.parseNext();
  return new ResultIterator<T,ParsingContext>(){
    @Override public boolean hasNext(){
      return !parser.getContext().isStopped() || beanHolder[0] != null;
    }
    @Override public T next(){
      T out=(T)beanHolder[0];
      if (parser.parseNext() == null) {
        beanHolder[0]=null;
      }
      return out;
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
    @Override public ParsingContext getContext(){
      return context;
    }
  }
;
}

Fixed version (ground truth):
@Override public ResultIterator<T,ParsingContext> iterator(){
  final AbstractParser<P> parser=createParser(parserSettings);
  parser.beginParsing(input);
  context=parser.getContext();
  return new ResultIterator<T,ParsingContext>(){
    @Override public boolean hasNext(){
      return beanHolder[0] != null || parser.parseNext() != null;
    }
    @Override public T next(){
      if (hasNext()) {
        T out=(T)beanHolder[0];
        beanHolder[0]=null;
        return out;
      }
      return null;
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
    @Override public ParsingContext getContext(){
      return context;
    }
  }
;
}
Program: 163266
Project: 163266
Buggy source:
@Override public boolean hasNext(){
  return !parser.getContext().isStopped() || beanHolder[0] != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return beanHolder[0] != null || parser.parseNext() != null;
}
Program: 163267
Project: 163267
Buggy source:
@Override protected void configureFromAnnotations(Class<?> beanClass){
  if (fieldLengths == null) {
    try {
      fieldLengths=FixedWidthFields.forParsing(beanClass);
      Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
      setHeaderExtractionEnabled(headerAnnotation != null && headerAnnotation.extract());
    }
 catch (    IllegalArgumentException e) {
      throw e;
    }
catch (    Exception ex) {
    }
  }
  super.configureFromAnnotations(beanClass);
  if (!isHeaderExtractionEnabled()) {
    FixedWidthFields.setHeadersIfPossible(fieldLengths,this);
  }
}

Fixed version (ground truth):
@Override protected void configureFromAnnotations(Class<?> beanClass){
  if (fieldLengths == null) {
    try {
      fieldLengths=FixedWidthFields.forParsing(beanClass);
      Headers headerAnnotation=AnnotationHelper.findHeadersAnnotation(beanClass);
      if (headerExtractionEnabled == null && headerAnnotation != null) {
        setHeaderExtractionEnabled(headerAnnotation.extract());
      }
    }
 catch (    IllegalArgumentException e) {
      throw e;
    }
catch (    Exception ex) {
    }
  }
  if (headerExtractionEnabled == null) {
    setHeaderExtractionEnabled(false);
  }
  super.configureFromAnnotations(beanClass);
  if (!isHeaderExtractionEnabled()) {
    FixedWidthFields.setHeadersIfPossible(fieldLengths,this);
  }
}
Program: 163268
Project: 163268
Buggy source:
@Override public T next(){
  if (hasNext()) {
    T out=(T)beanHolder[0];
    beanHolder[0]=null;
    return out;
  }
  return null;
}

Fixed version (ground truth):
@Override public T next(){
  T out=(T)beanHolder[0];
  if (out == null && hasNext()) {
    out=(T)beanHolder[0];
  }
  beanHolder[0]=null;
  row=null;
  return out;
}
Program: 163269
Project: 163269
Buggy source:
@Override public ResultIterator<T,ParsingContext> iterator(){
  final AbstractParser<P> parser=createParser(parserSettings);
  parser.beginParsing(input);
  context=parser.getContext();
  return new ResultIterator<T,ParsingContext>(){
    @Override public boolean hasNext(){
      return beanHolder[0] != null || parser.parseNext() != null;
    }
    @Override public T next(){
      if (hasNext()) {
        T out=(T)beanHolder[0];
        beanHolder[0]=null;
        return out;
      }
      return null;
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
    @Override public ParsingContext getContext(){
      return context;
    }
  }
;
}

Fixed version (ground truth):
@Override public ResultIterator<T,ParsingContext> iterator(){
  final AbstractParser<P> parser=createParser(parserSettings);
  parser.beginParsing(input);
  context=parser.getContext();
  return new ResultIterator<T,ParsingContext>(){
    String[] row;
    @Override public boolean hasNext(){
      return beanHolder[0] != null || row != null || (row=parser.parseNext()) != null;
    }
    @Override public T next(){
      T out=(T)beanHolder[0];
      if (out == null && hasNext()) {
        out=(T)beanHolder[0];
      }
      beanHolder[0]=null;
      row=null;
      return out;
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
    @Override public ParsingContext getContext(){
      return context;
    }
  }
;
}
Program: 163271
Project: 163271
Buggy source:
@Override public boolean hasNext(){
  return beanHolder[0] != null || parser.parseNext() != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return beanHolder[0] != null || row != null || (row=parser.parseNext()) != null;
}