Program: 3257
Project: 3257
Buggy source:
/** 
 * Add an item to the CSV file, from a CSV line of elements
 * @param line The line of elements
 * @throws Exception Thrown if an error occurs when adding the item
 */
public void addItem(String line) throws Exception {
  boolean last=false;
  if (line.endsWith(fieldSeparator)) {
    last=true;
    line+="String_Node_Str";
  }
  String[] parts=line.split(escapedFieldSeparator);
  ArrayList<String> bits=new ArrayList<String>();
  bits.addAll(Arrays.asList(parts));
  boolean alldone=false;
  while (!alldone) {
    boolean found=false;
    int i=0;
    for (    String part : bits) {
      int bitcounter=part.length() - part.replaceAll("String_Node_Str","String_Node_Str").length();
      if ((part.startsWith("String_Node_Str")) && ((!part.endsWith("String_Node_Str")) || ((bitcounter % 2) == 1))) {
        found=true;
        String add=bits.get(i) + fieldSeparator + bits.get(i + 1);
        bits.remove(i);
        bits.add(i,add);
        bits.remove(i + 1);
        break;
      }
      i++;
    }
    alldone=!found;
  }
  int i=0;
  for (  String part : bits) {
    if ((part.startsWith("String_Node_Str")) && (part.endsWith("String_Node_Str"))) {
      part=part.substring(1,part.length() - 1);
      bits.set(i,part);
    }
    i++;
  }
  i=0;
  for (  String part : bits) {
    if (part.contains("String_Node_Str")) {
      part=part.replaceAll("String_Node_Str","String_Node_Str");
      bits.set(i,part);
    }
    i++;
  }
  String id=parts[0].replaceAll("String_Node_Str","String_Node_Str");
  DSpaceCSVLine csvLine;
  if ("String_Node_Str".equals(id)) {
    csvLine=new DSpaceCSVLine();
  }
 else {
    try {
      csvLine=new DSpaceCSVLine(Integer.parseInt(id));
    }
 catch (    NumberFormatException nfe) {
      System.err.println("String_Node_Str" + id);
      System.err.println("String_Node_Str" + "String_Node_Str");
      throw (nfe);
    }
  }
  i=0;
  for (  String part : bits) {
    if (i > 0) {
      if ((last) && (i == headings.size())) {
        part="String_Node_Str";
      }
      csvLine.add(headings.get(i - 1),null);
      String[] elements=part.split(escpaedValueSeparator);
      for (      String element : elements) {
        if ((element != null) && (!"String_Node_Str".equals(element))) {
          csvLine.add(headings.get(i - 1),element);
        }
      }
    }
    i++;
  }
  lines.add(csvLine);
  counter++;
}

Fixed version (ground truth):
/** 
 * Add an item to the CSV file, from a CSV line of elements
 * @param line The line of elements
 * @throws Exception Thrown if an error occurs when adding the item
 */
public void addItem(String line) throws Exception {
  boolean last=false;
  if (line.endsWith(fieldSeparator)) {
    last=true;
    line+="String_Node_Str";
  }
  String[] parts=line.split(escapedFieldSeparator);
  ArrayList<String> bits=new ArrayList<String>();
  bits.addAll(Arrays.asList(parts));
  boolean alldone=false;
  while (!alldone) {
    boolean found=false;
    int i=0;
    for (    String part : bits) {
      int bitcounter=part.length() - part.replaceAll("String_Node_Str","String_Node_Str").length();
      if ((part.startsWith("String_Node_Str")) && ((!part.endsWith("String_Node_Str")) || ((bitcounter % 2) == 1))) {
        found=true;
        String add=bits.get(i) + fieldSeparator + bits.get(i + 1);
        bits.remove(i);
        bits.add(i,add);
        bits.remove(i + 1);
        break;
      }
      i++;
    }
    alldone=!found;
  }
  int i=0;
  for (  String part : bits) {
    if ((part.startsWith("String_Node_Str")) && (part.endsWith("String_Node_Str"))) {
      part=part.substring(1,part.length() - 1);
      bits.set(i,part);
    }
    i++;
  }
  i=0;
  for (  String part : bits) {
    if (part.contains("String_Node_Str")) {
      part=part.replaceAll("String_Node_Str","String_Node_Str");
      bits.set(i,part);
    }
    i++;
  }
  String id=parts[0].replaceAll("String_Node_Str","String_Node_Str");
  DSpaceCSVLine csvLine;
  if ("String_Node_Str".equals(id)) {
    csvLine=new DSpaceCSVLine();
  }
 else {
    try {
      csvLine=new DSpaceCSVLine(Integer.parseInt(id));
    }
 catch (    NumberFormatException nfe) {
      System.err.println("String_Node_Str" + id);
      System.err.println("String_Node_Str" + "String_Node_Str");
      throw (nfe);
    }
  }
  i=0;
  for (  String part : bits) {
    if (i > 0) {
      if ((last) && (i == headings.size())) {
        part="String_Node_Str";
      }
      csvLine.add(headings.get(i - 1),null);
      String[] elements=part.split(escapedValueSeparator);
      for (      String element : elements) {
        if ((element != null) && (!"String_Node_Str".equals(element))) {
          csvLine.add(headings.get(i - 1),element);
        }
      }
    }
    i++;
  }
  lines.add(csvLine);
  counter++;
}