Program: 3670
Project: 3670
Buggy source:
/** 
 * Set relevant DC fields in an item from series/number values in the form. Some fields are repeatable in the form.  If this is the case, and the field is "relation.ispartof", the names in the request will be from the fields as follows: relation_ispartof_series_0 relation_ispartof_number_0 relation_ispartof_series_1 relation_ispartof_number_1 and so on.  If the field is unqualified: relation_series_0 relation_number_0 Otherwise the parameters are of the form: relation_ispartof_series relation_ispartof_number The values will be put in separate DCValues, in the form "last name, first name(s)", ordered as they appear in the list. These will replace any existing values.
 * @param request    the request object
 * @param item       the item to update
 * @param element    the DC element
 * @param qualifier  the DC qualifier, or null if unqualified
 * @param repeated   set to true if the field is repeatable on the form
 */
private void readSeriesNumbers(HttpServletRequest request,Item item,String element,String qualifier,boolean repeated){
  String dcname=element;
  if (qualifier != null) {
    dcname=element + "String_Node_Str" + qualifier;
  }
  List series=new LinkedList();
  List numbers=new LinkedList();
  if (repeated) {
    series=getRepeatedParameter(request,dcname + "String_Node_Str");
    numbers=getRepeatedParameter(request,dcname + "String_Node_Str");
    String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
    String removeButton="String_Node_Str" + dcname + "String_Node_Str";
    if (buttonPressed.startsWith(removeButton)) {
      int valToRemove=Integer.parseInt(buttonPressed.substring(removeButton.length()));
      series.remove(valToRemove);
      numbers.remove(valToRemove);
    }
  }
 else {
    String s=request.getParameter(dcname + "String_Node_Str");
    String n=request.getParameter(dcname + "String_Node_Str");
    if (s != null && !s.equals("String_Node_Str")) {
      series.add(s);
      numbers.add(n);
    }
  }
  item.clearDC(element,qualifier,Item.ANY);
  for (int i=0; i < series.size(); i++) {
    String s=((String)series.get(i)).trim();
    String n=((String)numbers.get(i)).trim();
    item.addDC(element,qualifier,null,new DCSeriesNumber(s,n).toString());
  }
}

Fixed version (ground truth):
/** 
 * Set relevant DC fields in an item from series/number values in the form. Some fields are repeatable in the form.  If this is the case, and the field is "relation.ispartof", the names in the request will be from the fields as follows: relation_ispartof_series_0 relation_ispartof_number_0 relation_ispartof_series_1 relation_ispartof_number_1 and so on.  If the field is unqualified: relation_series_0 relation_number_0 Otherwise the parameters are of the form: relation_ispartof_series relation_ispartof_number The values will be put in separate DCValues, in the form "last name, first name(s)", ordered as they appear in the list. These will replace any existing values.
 * @param request    the request object
 * @param item       the item to update
 * @param element    the DC element
 * @param qualifier  the DC qualifier, or null if unqualified
 * @param repeated   set to true if the field is repeatable on the form
 */
private void readSeriesNumbers(HttpServletRequest request,Item item,String element,String qualifier,boolean repeated){
  String dcname=element;
  if (qualifier != null) {
    dcname=element + "String_Node_Str" + qualifier;
  }
  List series=new LinkedList();
  List numbers=new LinkedList();
  if (repeated) {
    series=getRepeatedParameter(request,dcname + "String_Node_Str");
    numbers=getRepeatedParameter(request,dcname + "String_Node_Str");
    String buttonPressed=UIUtil.getSubmitButton(request,"String_Node_Str");
    String removeButton="String_Node_Str" + dcname + "String_Node_Str";
    if (buttonPressed.startsWith(removeButton)) {
      int valToRemove=Integer.parseInt(buttonPressed.substring(removeButton.length()));
      series.remove(valToRemove);
      numbers.remove(valToRemove);
    }
  }
 else {
    String s=request.getParameter(dcname + "String_Node_Str");
    String n=request.getParameter(dcname + "String_Node_Str");
    if (s != null && !s.equals("String_Node_Str")) {
      series.add(s);
      numbers.add(n);
    }
  }
  item.clearDC(element,qualifier,Item.ANY);
  for (int i=0; i < series.size(); i++) {
    String s=((String)series.get(i)).trim();
    String n=((String)numbers.get(i)).trim();
    if (!s.equals("String_Node_Str") || !n.equals("String_Node_Str")) {
      item.addDC(element,qualifier,null,new DCSeriesNumber(s,n).toString());
    }
  }
}