nus-yam/ex-repair huggingface dataset:
Program: 163273
Project: 163273
Buggy source:
/** 
 * Parses a single line from a String in the format supported by the parser implementation.
 * @param line a line of text to be parsed
 * @return the values parsed from the input line
 */
public final String[] parseLine(String line){
  if (line == null || line.isEmpty()) {
    return null;
  }
  lineReader.setLine(line);
  if (context == null || context.isStopped()) {
    beginParsing(lineReader);
  }
 else {
    ((DefaultCharInputReader)input).reloadBuffer();
  }
  try {
    while (!context.isStopped()) {
      ch=input.nextChar();
      if (inComment()) {
        processComment();
        return null;
      }
      input.markRecordStart();
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (processor != NoopProcessor.instance) {
          rowProcessed(row);
        }
        return row;
      }
    }
    return null;
  }
 catch (  EOFException ex) {
    return handleEOF();
  }
catch (  NullPointerException ex) {
    if (input != null) {
      stopParsing(null);
    }
    throw new IllegalStateException("String_Node_Str",ex);
  }
catch (  Throwable ex) {
    try {
      ex=handleException(ex);
    }
  finally {
      stopParsing(ex);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Parses a single line from a String in the format supported by the parser implementation.
 * @param line a line of text to be parsed
 * @return the values parsed from the input line
 */
public final String[] parseLine(String line){
  if (line == null || line.isEmpty()) {
    return null;
  }
  lineReader.setLine(line);
  if (context == null || context.isStopped()) {
    beginParsing(lineReader);
  }
 else {
    ((DefaultCharInputReader)input).reloadBuffer();
  }
  try {
    while (!context.isStopped()) {
      input.markRecordStart();
      ch=input.nextChar();
      if (inComment()) {
        processComment();
        return null;
      }
      parseRecord();
      String[] row=output.rowParsed();
      if (row != null) {
        if (processor != NoopProcessor.instance) {
          rowProcessed(row);
        }
        return row;
      }
    }
    return null;
  }
 catch (  EOFException ex) {
    return handleEOF();
  }
catch (  NullPointerException ex) {
    if (input != null) {
      stopParsing(null);
    }
    throw new IllegalStateException("String_Node_Str",ex);
  }
catch (  Throwable ex) {
    try {
      ex=handleException(ex);
    }
  finally {
      stopParsing(ex);
    }
  }
  return null;
}
Program: 163274
Project: 163274
Buggy source:
@Override public final void markRecordStart(){
  tmp.reset();
  if (length == -1) {
    tmp.append(ch);
  }
  recordStart=i <= 0 ? 0 : i - 1;
}

Fixed version (ground truth):
@Override public final void markRecordStart(){
  tmp.reset();
  recordStart=i % length;
}
Program: 163275
Project: 163275
Buggy source:
@DataProvider public Object[][] inputBufferSizeProvider(){
  return new Object[][]{{2},{3},{4},{5},{6},{7},{8}};
}

Fixed version (ground truth):
@DataProvider public Object[][] inputBufferSizeProvider(){
  return new Object[][]{{1},{2},{3},{4},{5},{6},{7},{8}};
}
Program: 163276
Project: 163276
Buggy source:
@Test(dataProvider="String_Node_Str") public void testCurrentParsedContentWithShortString(int inputBufferSize) throws IOException {
  CsvParserSettings settings=new CsvParserSettings();
  settings.setReadInputOnSeparateThread(false);
  settings.setInputBufferSize(inputBufferSize);
  settings.getFormat().setLineSeparator("String_Node_Str");
  CsvParser parser=new CsvParser(settings);
  parser.beginParsing(new StringReader("String_Node_Str"));
  parser.parseNext();
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.stopParsing();
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
}

Fixed version (ground truth):
@Test(dataProvider="String_Node_Str") public void testCurrentParsedContentWithShortString(int inputBufferSize) throws IOException {
  CsvParserSettings settings=new CsvParserSettings();
  settings.setReadInputOnSeparateThread(false);
  settings.setInputBufferSize(inputBufferSize);
  settings.getFormat().setLineSeparator("String_Node_Str");
  CsvParser parser=new CsvParser(settings);
  parser.beginParsing(new StringReader("String_Node_Str"));
  parser.parseNext();
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.stopParsing();
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),null);
  parser.beginParsing(new StringReader("String_Node_Str"));
  parser.parseNext();
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parseNext();
  assertEquals(parser.getContext().currentParsedContent(),"String_Node_Str");
  parser.parseNext();
  assertEquals(parser.getContext().currentParsedContent(),null);
  parser.stopParsing();
  parser.parse(new StringReader("String_Node_Str"));
  assertEquals(parser.getContext().currentParsedContent(),null);
}
Program: 163278
Project: 163278
Buggy source:
private Statement populateDatabase() throws Exception {
  String createTable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Class.forName("String_Node_Str");
  Connection connection=DriverManager.getConnection("String_Node_Str");
  Statement statement=connection.createStatement();
  statement.execute(createTable);
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  return statement;
}

Fixed version (ground truth):
protected Statement populateDatabase() throws Exception {
  String createTable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Class.forName("String_Node_Str");
  Connection connection=DriverManager.getConnection("String_Node_Str");
  Statement statement=connection.createStatement();
  statement.execute(createTable);
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  return statement;
}
Program: 163279
Project: 163279
Buggy source:
@Override public final void markRecordStart(){
  tmp.reset();
  recordStart=i <= 0 ? 0 : i - 1;
}

Fixed version (ground truth):
@Override public final void markRecordStart(){
  tmp.reset();
  if (length == -1) {
    tmp.append(ch);
  }
  recordStart=i <= 0 ? 0 : i - 1;
}
Program: 163280
Project: 163280
Buggy source:
private void initializeMetadataConversions(String[] data,MetaData md){
  if (conversions != null) {
    String[] headers=headers();
    if (headers == null) {
      headers=data;
    }
    conversions.prepareExecution(false,headers);
    md.setDefaultConversions(conversions.getConversions(md.index,md.type));
  }
}

Fixed version (ground truth):
private void initializeMetadataConversions(String[] data,MetaData md){
  if (conversions != null) {
synchronized (this) {
      String[] headers=headers();
      if (headers == null) {
        headers=data;
      }
      conversions.prepareExecution(false,headers);
      md.setDefaultConversions(conversions.getConversions(md.index,md.type));
    }
  }
}
Program: 163281
Project: 163281
Buggy source:
public MetaData getMetaData(int index){
  if (indexMap == null || indexMap.length < index + 1) {
    int startFrom=0;
    int lastIndex=index;
    if (indexMap != null) {
      startFrom=indexMap.length;
      indexMap=Arrays.copyOf(indexMap,index + 1);
    }
 else {
      String[] headers=context.headers();
      if (headers != null && lastIndex < headers.length) {
        lastIndex=headers.length;
      }
      int[] indexes=context.extractedFieldIndexes();
      if (indexes != null) {
        for (int i=0; i < indexes.length; i++) {
          if (lastIndex < indexes[i]) {
            lastIndex=indexes[i];
          }
        }
      }
      indexMap=new MetaData[lastIndex + 1];
    }
    for (int i=startFrom; i < lastIndex + 1; i++) {
      indexMap[i]=new MetaData(i);
    }
  }
  return indexMap[index];
}

Fixed version (ground truth):
public MetaData getMetaData(int index){
  if (indexMap == null || indexMap.length < index + 1 || indexMap[index] == null) {
synchronized (this) {
      if (indexMap == null || indexMap.length < index + 1 || indexMap[index] == null) {
        int startFrom=0;
        int lastIndex=index;
        if (indexMap != null) {
          startFrom=indexMap.length;
          indexMap=Arrays.copyOf(indexMap,index + 1);
        }
 else {
          String[] headers=context.headers();
          if (headers != null && lastIndex < headers.length) {
            lastIndex=headers.length;
          }
          int[] indexes=context.extractedFieldIndexes();
          if (indexes != null) {
            for (int i=0; i < indexes.length; i++) {
              if (lastIndex < indexes[i]) {
                lastIndex=indexes[i];
              }
            }
          }
          indexMap=new MetaData[lastIndex + 1];
        }
        for (int i=startFrom; i < lastIndex + 1; i++) {
          indexMap[i]=new MetaData(i);
        }
      }
    }
  }
  return indexMap[index];
}
Program: 163282
Project: 163282
Buggy source:
/** 
 * Converts a formatted date String to an instance of Date. <p>The pattern in the formatted date must match one of the date patterns provided in the constructor of this class.
 * @param input the String containing a formatted date which must be converted to a Date
 * @return the Date instance containing the date information represented by the given String, or the value of {@code valueIfObjectIsNull} if the String input is null.
 */
@Override protected Date fromString(String input){
  for (  SimpleDateFormat formatter : parsers) {
    try {
      return formatter.parse(input);
    }
 catch (    ParseException ex) {
    }
  }
  DataProcessingException exception=new DataProcessingException("String_Node_Str" + Arrays.toString(formats));
  exception.setValue(input);
  throw exception;
}

Fixed version (ground truth):
/** 
 * Converts a formatted date String to an instance of Date. <p>The pattern in the formatted date must match one of the date patterns provided in the constructor of this class.
 * @param input the String containing a formatted date which must be converted to a Date
 * @return the Date instance containing the date information represented by the given String, or the value of {@code valueIfObjectIsNull} if the String input is null.
 */
@Override protected Date fromString(String input){
  for (  SimpleDateFormat formatter : parsers) {
    try {
synchronized (formatter) {
        return formatter.parse(input);
      }
    }
 catch (    ParseException ex) {
    }
  }
  DataProcessingException exception=new DataProcessingException("String_Node_Str" + Arrays.toString(formats));
  exception.setValue(input);
  throw exception;
}
Program: 163283
Project: 163283
Buggy source:
@Override public final void start(Reader reader){
  stop();
  setReader(reader);
  lineCount=0;
  lineSeparatorDetected=false;
  submitLineSeparatorDetector();
  updateBuffer();
}

Fixed version (ground truth):
@Override public final void start(Reader reader){
  stop();
  setReader(reader);
  lineCount=0;
  lineSeparatorDetected=false;
  submitLineSeparatorDetector();
  updateBuffer();
  if (length > 0 && buffer[0] == '\uFEFF') {
    i++;
  }
}
Program: 163284
Project: 163284
Buggy source:
private void processQuoteEscape(){
  if (ch == quoteEscape && prev == escapeEscape && escapeEscape != '\0') {
    if (keepEscape) {
      output.appender.append(escapeEscape);
    }
    output.appender.append(quoteEscape);
    ch='\0';
  }
 else   if (prev == quoteEscape) {
    if (ch == quote) {
      if (keepEscape) {
        output.appender.append(quoteEscape);
      }
      output.appender.append(quote);
      ch='\0';
    }
 else {
      output.appender.append(prev);
    }
  }
 else   if (ch == quote && prev == quote) {
    output.appender.append(quote);
  }
}

Fixed version (ground truth):
private void processQuoteEscape(){
  if (ch == quoteEscape && prev == escapeEscape && escapeEscape != '\0') {
    if (keepEscape) {
      output.appender.append(escapeEscape);
    }
    output.appender.append(quoteEscape);
    ch='\0';
  }
 else   if (prev == quoteEscape) {
    if (ch == quote) {
      if (keepEscape) {
        output.appender.append(quoteEscape);
      }
      output.appender.append(quote);
      ch='\0';
    }
 else {
      output.appender.append(prev);
    }
  }
 else   if (ch == quote && prev == quote) {
    output.appender.append(quote);
  }
 else   if (prev == quote) {
    handleUnescapedQuoteInValue();
  }
}
Program: 163286
Project: 163286
Buggy source:
@Test(dataProvider="String_Node_Str") public void testEscapeWriting(String input){
  System.out.println("String_Node_Str" + input + "String_Node_Str");
  int i=0;
  for (  char escape : new char[]{'\'','|'}) {
    CsvWriterSettings settings=new CsvWriterSettings();
    settings.setEscapeUnquotedValues(true);
    settings.getFormat().setQuote('\'');
    settings.getFormat().setQuoteEscape(escape);
    System.out.print(++i + "String_Node_Str" + escape+ "String_Node_Str");
    String result=new CsvWriter(settings).writeRowToString(input);
    CsvParserSettings parserSettings=new CsvParserSettings();
    settings.setEscapeUnquotedValues(true);
    settings.getFormat().setQuote('\'');
    settings.getFormat().setQuoteEscape(escape);
    String parsed=new CsvParser(parserSettings).parseLine(input)[0];
    System.out.println(result + (parsed.equals(input) ? "String_Node_Str" : "String_Node_Str"));
    assertEquals(parsed,input);
  }
}

Fixed version (ground truth):
@Test(dataProvider="String_Node_Str") public void testEscapeWriting(String input){
  System.out.println("String_Node_Str" + input + "String_Node_Str");
  int i=0;
  List<String> expected=new ArrayList<String>();
  for (  char escape : new char[]{'\'','|'}) {
    CsvWriterSettings settings=new CsvWriterSettings();
    settings.setQuoteAllFields(true);
    settings.getFormat().setQuote('\'');
    settings.getFormat().setQuoteEscape(escape);
    System.out.print(++i + "String_Node_Str" + escape+ "String_Node_Str");
    String result=new CsvWriter(settings).writeRowToString(input);
    CsvParserSettings parserSettings=new CsvParserSettings();
    settings.setEscapeUnquotedValues(true);
    settings.getFormat().setQuote('\'');
    settings.getFormat().setQuoteEscape(escape);
    String parsed=new CsvParser(parserSettings).parseLine(input)[0];
    System.out.println(result + (parsed.equals(input) ? "String_Node_Str" : "String_Node_Str"));
    assertEquals(parsed,input);
    expected.add(result);
  }
}
Program: 163288
Project: 163288
Buggy source:
/** 
 * The FixedWidthWriter supports all settings provided by   {@link FixedWidthWriterSettings}, and requires this configuration to be properly initialized.
 * @param output the output stream that will be written with the fixed-width records produced by this class.
 * @param encoding the encoding of the stream
 * @param settings the fixed-width writer configuration
 */
public FixedWidthWriter(OutputStream output,Charset encoding,FixedWidthWriterSettings settings){
  super(output,encoding,settings);
}

Fixed version (ground truth):
/** 
 * The FixedWidthWriter supports all settings provided by   {@link FixedWidthWriterSettings}, and requires this configuration to be properly initialized.
 * @param output   the output stream that will be written with the fixed-width records produced by this class.
 * @param encoding the encoding of the stream
 * @param settings the fixed-width writer configuration
 */
public FixedWidthWriter(OutputStream output,Charset encoding,FixedWidthWriterSettings settings){
  super(output,encoding,settings);
}
Program: 163290
Project: 163290
Buggy source:
protected Statement populateDatabase() throws Exception {
  String createTable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Class.forName("String_Node_Str");
  Connection connection=DriverManager.getConnection("String_Node_Str");
  Statement statement=connection.createStatement();
  statement.execute(createTable);
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  return statement;
}

Fixed version (ground truth):
protected Statement populateDatabase() throws Exception {
  String createTable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Class.forName("String_Node_Str");
  Statement statement=connectToDatabase();
  statement.execute(createTable);
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  statement.executeUpdate("String_Node_Str");
  return statement;
}
Program: 163291
Project: 163291
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 (error != null) {
        ArgumentUtils.throwUnchecked(error);
      }
      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: 163292
Project: 163292
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 (  IOException e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
 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(){
  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 (  Exception e) {
    finished=true;
    error=e;
  }
 finally {
    stopReading();
  }
}
Program: 163293
Project: 163293
Buggy source:
/** 
 * Returns the metadata information associated with the records generated by this factory class
 * @return the record metadata.
 */
public final RecordMetaData getRecordMetaData(){
  return metaData;
}

Fixed version (ground truth):
/** 
 * Returns the metadata information associated with the records generated by this factory class
 * @return the record metadata.
 */
public final M getRecordMetaData(){
  return metaData;
}
Program: 163294
Project: 163294
Buggy source:
/** 
 * Creates a new factory of   {@link Record} based the state of a parser
 * @param context            the parser context
 */
public AbstractRecordFactory(Context context){
  this.metaData=new RecordMetaDataImpl(context);
}

Fixed version (ground truth):
/** 
 * Creates a new factory of   {@link Record} based the state of a parser
 * @param context            the parser context
 */
public AbstractRecordFactory(Context context){
  this.metaData=createMetaData(context);
}
Program: 163295
Project: 163295
Buggy source:
RecordMetaDataImpl(Context context){
  this.context=context;
}

Fixed version (ground truth):
RecordMetaDataImpl(C context){
  this.context=context;
}
Program: 163296
Project: 163296
Buggy source:
protected void adjustColumnLengths(String[] headers,int[] lengths){
  getWriterSettings().setFieldLengths(new FixedWidthFields(headers,lengths));
}

Fixed version (ground truth):
protected void adjustColumnLengths(String[] headers,int[] lengths){
  if (getWriterSettings().getFieldLengths() == null) {
    getWriterSettings().setFieldLengths(new FixedWidthFields(headers,lengths));
  }
}
Program: 163298
Project: 163298
Buggy source:
/** 
 * Stops parsing and closes all open resources.
 */
public final void stopParsing(){
  try {
    context.stop();
  }
  finally {
    try {
      processor.processEnded(context);
    }
  finally {
      output.appender.reset();
      input.stop();
    }
  }
}

Fixed version (ground truth):
/** 
 * 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);
  }
}
Program: 163299
Project: 163299
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();
  }
}

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 (bucketLoader != null) {
    bucketLoader.stopReading();
    bucketLoader.reportError();
  }
}
Program: 163300
Project: 163300
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);
}

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){
  stop();
  bucketLoader=new ConcurrentCharLoader(reader,bucketSize,bucketQuantity);
  bucketLoader.reportError();
}
Program: 163301
Project: 163301
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();
  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(){
  CharBucket currentBucket=bucketLoader.nextBucket();
  bucketLoader.reportError();
  super.buffer=currentBucket.data;
  super.length=currentBucket.length;
}
Program: 163302
Project: 163302
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 (error != null) {
        ArgumentUtils.throwUnchecked(error);
      }
      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) {
      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: 163303
Project: 163303
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;
  activeExecution=new Thread(this,"String_Node_Str");
  activeExecution.start();
}
Program: 163304
Project: 163304
Buggy source:
@Test(expectedExceptions=TextParsingException.class) public void parseExceptionInConcurrentInput() throws Exception {
  Reader explodingInput=new Reader(){
    String firstPart="String_Node_Str";
    @Override public int read(    char[] chars,    int off,    int len) throws IOException {
      if (firstPart != null) {
        for (int i=0; i < firstPart.length() && len-- > 0; i++) {
          chars[off++]=firstPart.charAt(i);
        }
        int out=firstPart.length();
        firstPart=null;
        return out;
      }
      throw new IllegalStateException("String_Node_Str");
    }
    @Override public void close() throws IOException {
    }
  }
;
  CsvParserSettings settings=new CsvParserSettings();
  System.err.println("String_Node_Str");
  CsvParser parser=new CsvParser(settings);
  parser.beginParsing(explodingInput);
  assertEquals("String_Node_Str",Arrays.toString(parser.parseNext()));
  assertEquals("String_Node_Str",Arrays.toString(parser.parseNext()));
  parser.parseNext();
  fail("String_Node_Str");
}

Fixed version (ground truth):
@Test(expectedExceptions=TextParsingException.class) public void parseExceptionInConcurrentInput() throws Exception {
  Reader explodingInput=new Reader(){
    String firstPart="String_Node_Str";
    @Override public int read(    char[] chars,    int off,    int len) throws IOException {
      if (firstPart != null) {
        for (int i=0; i < firstPart.length() && len-- > 0; i++) {
          chars[off++]=firstPart.charAt(i);
        }
        int out=firstPart.length();
        firstPart=null;
        return out;
      }
      throw new IllegalStateException("String_Node_Str");
    }
    @Override public void close() throws IOException {
    }
  }
;
  CsvParserSettings settings=new CsvParserSettings();
  System.err.println("String_Node_Str");
  CsvParser parser=new CsvParser(settings);
  parser.beginParsing(explodingInput);
  assertEquals(Arrays.toString(parser.parseNext()),"String_Node_Str");
  assertEquals(Arrays.toString(parser.parseNext()),"String_Node_Str");
  System.out.println(Arrays.toString(parser.parseNext()));
  fail("String_Node_Str");
}
Program: 163305
Project: 163305
Buggy source:
/** 
 * Initializes the ParserOutput with the configuration specified in   {@link CommonParserSettings}
 * @param parser the parser whose output will be managed by this class.
 * @param settings the parser configuration
 */
public ParserOutput(AbstractParser<?> parser,CommonParserSettings<?> settings){
  this.parser=parser;
  this.appenderInstance=settings.newCharAppender();
  this.appender=appenderInstance;
  this.parsedValues=new String[settings.getMaxColumns()];
  this.appenders=new CharAppender[settings.getMaxColumns() + 1];
  Arrays.fill(appenders,appender);
  this.settings=settings;
  this.skipEmptyLines=settings.getSkipEmptyLines();
  this.nullValue=settings.getNullValue();
  this.columnsToExtractInitialized=false;
  this.currentRecord=0;
  if (settings.getHeaders() != null) {
    initializeHeaders();
  }
}

Fixed version (ground truth):
/** 
 * Initializes the ParserOutput with the configuration specified in   {@link CommonParserSettings}
 * @param parser   the parser whose output will be managed by this class.
 * @param settings the parser configuration
 */
public ParserOutput(AbstractParser<?> parser,CommonParserSettings<?> settings){
  this.parser=parser;
  this.appenderInstance=settings.newCharAppender();
  this.appender=appenderInstance;
  this.parsedValues=new String[settings.getMaxColumns()];
  this.appenders=new CharAppender[settings.getMaxColumns() + 1];
  Arrays.fill(appenders,appender);
  this.settings=settings;
  this.skipEmptyLines=settings.getSkipEmptyLines();
  this.nullValue=settings.getNullValue();
  this.columnsToExtractInitialized=false;
  this.currentRecord=0;
  if (settings.getHeaders() != null) {
    initializeHeaders();
  }
}
Program: 163307
Project: 163307
Buggy source:
private static void registerLookup(String direction,String lookup,FixedWidthFields lengths,Map<String,FixedWidthFields> map){
  if (lookup == null || lookup.trim().isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str" + direction + "String_Node_Str");
  }
  if (lengths == null) {
    throw new IllegalArgumentException("String_Node_Str" + direction + "String_Node_Str"+ lookup+ "String_Node_Str");
  }
  map.put(lookup,lengths);
}

Fixed version (ground truth):
private static void registerLookup(String direction,String lookup,FixedWidthFields lengths,Map<String,FixedWidthFields> map){
  if (lookup == null) {
    throw new IllegalArgumentException("String_Node_Str" + direction + "String_Node_Str");
  }
  if (lengths == null) {
    throw new IllegalArgumentException("String_Node_Str" + direction + "String_Node_Str"+ lookup+ "String_Node_Str");
  }
  map.put(lookup,lengths);
}
Program: 163309
Project: 163309
Buggy source:
@Test(dataProvider="String_Node_Str") public void testWriteNullValueAsEmptyQuotes(String nullValue,String emptyValue,boolean quoteAllFields,String expectedNullValue,String expectedEmptyValue){
  CsvWriterSettings s=new CsvWriterSettings();
  s.setNullValue(nullValue);
  s.setEmptyValue(emptyValue);
  s.setQuoteAllFields(quoteAllFields);
  String result;
  result=new CsvWriter(s).writeRowToString(new String[]{null,"String_Node_Str"});
  assertEquals(result,expectedNullValue + ',' + expectedEmptyValue);
}

Fixed version (ground truth):
@Test(dataProvider="String_Node_Str") public void testWriteNullValueAsEmptyQuotes(String nullValue,String emptyValue,boolean quoteAllFields,boolean quoteEscapingEnabled,String expectedNullValue,String expectedEmptyValue){
  CsvWriterSettings s=new CsvWriterSettings();
  s.setNullValue(nullValue);
  s.setEmptyValue(emptyValue);
  s.setQuoteAllFields(quoteAllFields);
  String result;
  result=new CsvWriter(s).writeRowToString(new String[]{null,"String_Node_Str"});
  assertEquals(result,expectedNullValue + ',' + expectedEmptyValue);
}
Program: 163311
Project: 163311
Buggy source:
/** 
 * Converts a given object to its String representation for writing to a   {@code String}<ul> <li>If the object is null, then   {@link AbstractWriter#nullValue} is returned.</li><li>If the String representation of this object is an empty String, then  {@link AbstractWriter#emptyValue} is returned</li></ul>
 * @param element the object to be converted into a String.
 * @return the String representation of the given object
 */
protected String getStringValue(Object element){
  if (element == null) {
    element=nullValue;
    if (element == null) {
      return null;
    }
  }
  String string=String.valueOf(element);
  if (string.isEmpty()) {
    return emptyValue;
  }
  return string;
}

Fixed version (ground truth):
/** 
 * Converts a given object to its String representation for writing to a   {@code String}<ul> <li>If the object is null, then   {@link AbstractWriter#nullValue} is returned.</li><li>If the String representation of this object is an empty String, then  {@link AbstractWriter#emptyValue} is returned</li></ul>
 * @param element the object to be converted into a String.
 * @return the String representation of the given object
 */
protected String getStringValue(Object element){
  usingNullOrEmptyValue=false;
  if (element == null) {
    element=nullValue;
    usingNullOrEmptyValue=true;
    if (element == null) {
      return null;
    }
  }
  String string=String.valueOf(element);
  if (string.isEmpty()) {
    usingNullOrEmptyValue=true;
    return emptyValue;
  }
  return string;
}
Program: 163313
Project: 163313
Buggy source:
@Test public void testWriteEmptyValue(){
  CsvWriterSettings s=new CsvWriterSettings();
  s.setNullValue("String_Node_Str");
  s.setEmptyValue("String_Node_Str");
  CsvWriter w=new CsvWriter(s);
  String result=w.writeRowToString(new String[]{null,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  System.out.println(result);
}

Fixed version (ground truth):
@Test public void testWriteEmptyValue(){
  CsvWriterSettings s=new CsvWriterSettings();
  s.setNullValue("String_Node_Str");
  s.setEmptyValue("String_Node_Str");
  CsvWriter w=new CsvWriter(s);
  String result=w.writeRowToString(new String[]{null,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  assertEquals(result,"String_Node_Str");
}
Program: 163314
Project: 163314
Buggy source:
private void skipToNewLine(){
  while (ch != newLine) {
    ch=input.nextChar();
  }
}

Fixed version (ground truth):
private void skipToNewLine(){
  try {
    while (ch != newLine) {
      ch=input.nextChar();
    }
  }
 catch (  EOFException e) {
  }
}
Program: 163316
Project: 163316
Buggy source:
/** 
 * Reads the value accessible by this field mapping from a given object
 * @param instance the object whose field, mapped by this field mapping, will be read
 * @return the value contained in the given instance's field
 */
public Object read(Object instance){
  setAccessible(readMethod);
  try {
    if (readMethod != null) {
      return readMethod.invoke(instance);
    }
 else {
      return field.get(instance);
    }
  }
 catch (  Throwable e) {
    throw new DataProcessingException("String_Node_Str" + field.getName() + "String_Node_Str"+ this.beanClass.getName(),e);
  }
}

Fixed version (ground truth):
private Object read(Object instance,boolean ignoreErrors){
  setAccessible(readMethod);
  try {
    if (readMethod != null) {
      return readMethod.invoke(instance);
    }
 else {
      return field.get(instance);
    }
  }
 catch (  Throwable e) {
    if (!ignoreErrors) {
      throw new DataProcessingException("String_Node_Str" + field.getName() + "String_Node_Str"+ this.beanClass.getName(),e);
    }
  }
  return null;
}
Program: 163317
Project: 163317
Buggy source:
/** 
 * Creates the mapping and identifies how it is mapped (by name or by index)
 * @param beanClass the class that contains a the given field.
 * @param field a {@link java.lang.reflect.Field} annotated with {@link Parsed}
 * @param property the property descriptor of this field, if any. If this bean does not have getters/setters, it will be accessed directly.
 */
public FieldMapping(Class<?> beanClass,Field field,PropertyWrapper property){
  this.beanClass=beanClass;
  this.field=field;
  this.readMethod=property != null ? property.getReadMethod() : null;
  this.writeMethod=property != null ? property.getWriteMethod() : null;
  determineFieldMapping();
}

Fixed version (ground truth):
/** 
 * Creates the mapping and identifies how it is mapped (by name or by index)
 * @param beanClass the class that contains a the given field.
 * @param field a {@link java.lang.reflect.Field} annotated with {@link Parsed}
 * @param property the property descriptor of this field, if any. If this bean does not have getters/setters, it will be accessed directly.
 */
public FieldMapping(Class<?> beanClass,Field field,PropertyWrapper property){
  this.beanClass=beanClass;
  this.field=field;
  this.readMethod=property != null ? property.getReadMethod() : null;
  this.writeMethod=property != null ? property.getWriteMethod() : null;
  Class typeToSet;
  if (field != null) {
    typeToSet=field.getType();
  }
 else   if (writeMethod != null && writeMethod.getParameterTypes().length == 1) {
    typeToSet=writeMethod.getParameterTypes()[0];
  }
 else {
    typeToSet=Object.class;
  }
  primitive=typeToSet.isPrimitive();
  defaultPrimitiveValue=getDefaultPrimitiveValue(typeToSet);
  determineFieldMapping();
}
Program: 163318
Project: 163318
Buggy source:
/** 
 * Writes a value to the field of a given object instance, whose field is accessible through this field mapping.
 * @param instance the object whose field will be set
 * @param value the value to set on the given object's field.
 */
public void write(Object instance,Object value){
  setAccessible(writeMethod);
  try {
    if (writeMethod != null) {
      writeMethod.invoke(instance,value);
    }
 else {
      field.set(instance,value);
    }
  }
 catch (  Throwable e) {
    DataProcessingException ex=new DataProcessingException("String_Node_Str" + field.getName() + "String_Node_Str"+ this.beanClass.getName(),e);
    ex.setValue(value);
    ex.markAsNonFatal();
    ex.setValue(value);
    throw ex;
  }
}

Fixed version (ground truth):
/** 
 * Writes a value to the field of a given object instance, whose field is accessible through this field mapping.
 * @param instance the object whose field will be set
 * @param value the value to set on the given object's field.
 */
public void write(Object instance,Object value){
  setAccessible(writeMethod);
  try {
    if (value == null && primitive) {
      if (applyDefault == null) {
        Object currentValue=read(instance,true);
        applyDefault=defaultPrimitiveValue.equals(currentValue);
      }
      if (applyDefault == Boolean.TRUE) {
        value=defaultPrimitiveValue;
      }
 else {
        return;
      }
    }
    if (writeMethod != null) {
      writeMethod.invoke(instance,value);
    }
 else {
      field.set(instance,value);
    }
  }
 catch (  Throwable e) {
    DataProcessingException ex=new DataProcessingException("String_Node_Str" + field.getName() + "String_Node_Str"+ this.beanClass.getName(),e);
    ex.markAsNonFatal();
    ex.setValue(value);
    throw ex;
  }
}
Program: 163319
Project: 163319
Buggy source:
private void initializeConversions(String[] row,Context context){
  conversionsInitialized=true;
  this.fieldIndexes=null;
  this.fieldsReordered=false;
  this.conversionsInitialized=false;
  String[] contextHeaders=context.headers();
  if (contextHeaders != null && contextHeaders.length > 0) {
    conversions.prepareExecution(false,contextHeaders);
  }
 else {
    conversions.prepareExecution(false,row);
  }
  this.fieldIndexes=context.extractedFieldIndexes();
  this.fieldsReordered=context.columnsReordered();
}

Fixed version (ground truth):
protected void initializeConversions(String[] row,Context context){
  conversionsInitialized=true;
  this.fieldIndexes=null;
  this.fieldsReordered=false;
  this.conversionsInitialized=false;
  String[] contextHeaders=context == null ? null : context.headers();
  if (contextHeaders != null && contextHeaders.length > 0) {
    conversions.prepareExecution(false,contextHeaders);
  }
 else {
    conversions.prepareExecution(false,row);
  }
  if (context != null) {
    this.fieldIndexes=context.extractedFieldIndexes();
    this.fieldsReordered=context.columnsReordered();
  }
}
Program: 163321
Project: 163321
Buggy source:
/** 
 * Associates a conversion to a field of the java bean class.
 * @param conversion The conversion object that must be executed against the given field
 * @param mapping    the helper object that contains information about how a field is mapped.
 */
@SuppressWarnings("String_Node_Str") private void addConversion(Conversion conversion,FieldMapping mapping){
  if (conversion == null) {
    return;
  }
  if (mapping.isMappedToIndex()) {
    this.convertIndexes(conversion).add(mapping.getIndex());
  }
 else {
    this.convertFields(conversion).add(mapping.getFieldName());
  }
}

Fixed version (ground truth):
protected void addConversion(Conversion conversion,FieldMapping mapping){
  if (conversion == null) {
    return;
  }
  convertFields(conversion).add(mapping.getFieldName());
}
Program: 163322
Project: 163322
Buggy source:
/** 
 * Goes through a list of objects and associates each value to a particular field of a java bean instance
 * @param instance the java bean instance that is going to have its properties set
 * @param row      the values to associate with each field of the javabean.
 * @param context  information about the current parsing process.
 */
void mapValuesToFields(T instance,Object[] row,Context context){
  if (row.length > lastFieldIndexMapped) {
    this.lastFieldIndexMapped=row.length;
    mapFieldIndexes(context,row,context.headers(),context.extractedFieldIndexes(),context.columnsReordered());
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  for (int i=0; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      Object value=row[i];
      field.write(instance,value);
    }
  }
}

Fixed version (ground truth):
/** 
 * Goes through a list of objects and associates each value to a particular field of a java bean instance
 * @param instance the java bean instance that is going to have its properties set
 * @param row      the values to associate with each field of the javabean.
 * @param context  information about the current parsing process.
 */
void mapValuesToFields(T instance,Object[] row,Context context){
  if (row.length > lastFieldIndexMapped) {
    this.lastFieldIndexMapped=row.length;
    mapFieldIndexes(context,row,context.headers(),context.extractedFieldIndexes(),context.columnsReordered());
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  int i=0;
  for (; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      Object value=row[i];
      field.write(instance,value);
    }
  }
  if (missing != null) {
    for (i=0; i < missing.length; i++) {
      Object value=valuesForMissing[i];
      if (value != null) {
        FieldMapping field=missing[i];
        field.write(instance,value);
      }
    }
  }
}
Program: 163323
Project: 163323
Buggy source:
@Override public String getString(char ch,char stop,boolean trim,String nullValue){
  if (i == 0) {
    return null;
  }
  int i=this.i;
  for (; ch != stop; ch=buffer[i++]) {
    if (i >= length) {
      return null;
    }
    if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i])) {
      break;
    }
  }
  int pos=this.i - 1;
  int len=i - this.i;
  this.i=i - 1;
  if (trim) {
    i=i - 2;
    while (buffer[i--] <= ' ') {
      len--;
    }
  }
  String out;
  if (len <= 0) {
    out=nullValue;
  }
 else {
    out=new String(buffer,pos,len);
  }
  nextChar();
  return out;
}

Fixed version (ground truth):
@Override public String getString(char ch,char stop,boolean trim,String nullValue,int maxLength){
  if (i == 0) {
    return null;
  }
  int i=this.i;
  for (; ch != stop; ch=buffer[i++]) {
    if (i >= length) {
      return null;
    }
    if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i])) {
      break;
    }
  }
  int pos=this.i - 1;
  int len=i - this.i;
  if (len > maxLength) {
    return null;
  }
  this.i=i - 1;
  if (trim) {
    i=i - 2;
    while (buffer[i--] <= ' ') {
      len--;
    }
  }
  String out;
  if (len <= 0) {
    out=nullValue;
  }
 else {
    out=new String(buffer,pos,len);
  }
  nextChar();
  return out;
}