Program: 61294
Project: 61294
Buggy source:
/** 
 * <p> Reads one line from the input file and adds the data to a   {@link Map} data structure which maps user IDsto preferences. This assumes that each line of the input file corresponds to one preference. After reading a line and determining which user and item the preference pertains to, the method should look to see if the data contains a mapping for the user ID already, and if not, add an empty  {@link List} of{@link Preference}s to the data. </p> <p> Note that if the line is empty or begins with '#' it will be ignored as a comment. </p>
 * @param line line from input data file
 * @param data all data read so far, as a mapping from user IDs to preferences
 */
protected void processLine(String line,FastByIDMap<?> data){
  if ((line.length() == 0) || (line.charAt(0) == COMMENT_CHAR)) {
    return;
  }
  int delimiterOne=line.indexOf(delimiter);
  if (delimiterOne < 0) {
    throw new IllegalArgumentException("String_Node_Str" + line);
  }
  int delimiterTwo=line.indexOf(delimiter,delimiterOne + 1);
  if (delimiterTwo < 0) {
    throw new IllegalArgumentException("String_Node_Str" + line);
  }
  int delimiterThree=line.indexOf(delimiter,delimiterTwo + 1);
  String userIDString=line.substring(0,delimiterOne);
  String itemIDString=line.substring(delimiterOne + 1,delimiterTwo);
  String preferenceValueString;
  if (delimiterThree > delimiterTwo) {
    preferenceValueString=line.substring(delimiterTwo + 1,delimiterThree);
  }
 else {
    preferenceValueString=line.substring(delimiterTwo + 1);
  }
  long userID=readUserIDFromString(userIDString);
  long itemID=readItemIDFromString(itemIDString);
  if (transpose) {
    long tmp=userID;
    userID=itemID;
    itemID=tmp;
  }
  Object maybePrefs=data.get(userID);
  if (maybePrefs instanceof PreferenceArray) {
    PreferenceArray prefs=(PreferenceArray)maybePrefs;
    if (preferenceValueString.length() == 0) {
      if (prefs != null) {
        boolean exists=false;
        int length=prefs.length();
        for (int i=0; i < length; i++) {
          if (prefs.getItemID(i) == itemID) {
            exists=true;
            break;
          }
        }
        if (exists) {
          if (length == 1) {
            data.remove(userID);
          }
 else {
            PreferenceArray newPrefs=new GenericUserPreferenceArray(length - 1);
            for (int i=0, j=0; i < length; i++, j++) {
              if (prefs.getItemID(i) == itemID) {
                j--;
              }
 else {
                newPrefs.set(j,prefs.get(i));
              }
            }
          }
        }
      }
    }
 else {
      float preferenceValue=Float.parseFloat(preferenceValueString);
      boolean exists=false;
      if (prefs != null) {
        for (int i=0; i < prefs.length(); i++) {
          if (prefs.getItemID(i) == itemID) {
            exists=true;
            prefs.setValue(i,preferenceValue);
            break;
          }
        }
      }
      if (!exists) {
        if (prefs == null) {
          prefs=new GenericUserPreferenceArray(1);
          ((FastByIDMap<PreferenceArray>)data).put(userID,prefs);
        }
 else {
          PreferenceArray newPrefs=new GenericUserPreferenceArray(prefs.length() + 1);
          for (int i=0, j=1; i < prefs.length(); i++, j++) {
            newPrefs.set(j,prefs.get(i));
          }
        }
        prefs.setUserID(0,userID);
        prefs.setItemID(0,itemID);
        prefs.setValue(0,preferenceValue);
      }
    }
  }
 else {
    Collection<Preference> prefs=(Collection<Preference>)maybePrefs;
    if (preferenceValueString.length() == 0) {
      if (prefs != null) {
        Iterator<Preference> prefsIterator=prefs.iterator();
        while (prefsIterator.hasNext()) {
          Preference pref=prefsIterator.next();
          if (pref.getItemID() == itemID) {
            prefsIterator.remove();
            break;
          }
        }
      }
    }
 else {
      float preferenceValue=Float.parseFloat(preferenceValueString);
      boolean exists=false;
      if (prefs != null) {
        for (        Preference pref : prefs) {
          if (pref.getItemID() == itemID) {
            exists=true;
            pref.setValue(preferenceValue);
            break;
          }
        }
      }
      if (!exists) {
        if (prefs == null) {
          prefs=new ArrayList<Preference>(2);
          ((FastByIDMap<Collection<Preference>>)data).put(userID,prefs);
        }
        prefs.add(new GenericPreference(userID,itemID,preferenceValue));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * <p> Reads one line from the input file and adds the data to a   {@link Map} data structure which maps user IDsto preferences. This assumes that each line of the input file corresponds to one preference. After reading a line and determining which user and item the preference pertains to, the method should look to see if the data contains a mapping for the user ID already, and if not, add an empty  {@link List} of{@link Preference}s to the data. </p> <p> Note that if the line is empty or begins with '#' it will be ignored as a comment. </p>
 * @param line line from input data file
 * @param data all data read so far, as a mapping from user IDs to preferences
 * @param fromPriorData an implementation detail -- if true, data will map IDs to{@link PreferenceArray} since the framework is attempting to read and update rawdata that is already in memory. Otherwise it maps to  {@link Collection}s of  {@link Preference}s, since it's reading fresh data. Subclasses must be prepared to handle this wrinkle.
 */
protected void processLine(String line,FastByIDMap<?> data,boolean fromPriorData){
  if ((line.length() == 0) || (line.charAt(0) == COMMENT_CHAR)) {
    return;
  }
  int delimiterOne=line.indexOf(delimiter);
  if (delimiterOne < 0) {
    throw new IllegalArgumentException("String_Node_Str" + line);
  }
  int delimiterTwo=line.indexOf(delimiter,delimiterOne + 1);
  if (delimiterTwo < 0) {
    throw new IllegalArgumentException("String_Node_Str" + line);
  }
  int delimiterThree=line.indexOf(delimiter,delimiterTwo + 1);
  String userIDString=line.substring(0,delimiterOne);
  String itemIDString=line.substring(delimiterOne + 1,delimiterTwo);
  String preferenceValueString;
  if (delimiterThree > delimiterTwo) {
    preferenceValueString=line.substring(delimiterTwo + 1,delimiterThree);
  }
 else {
    preferenceValueString=line.substring(delimiterTwo + 1);
  }
  long userID=readUserIDFromString(userIDString);
  long itemID=readItemIDFromString(itemIDString);
  if (transpose) {
    long tmp=userID;
    userID=itemID;
    itemID=tmp;
  }
  Object maybePrefs=data.get(userID);
  if (fromPriorData) {
    PreferenceArray prefs=(PreferenceArray)maybePrefs;
    if (preferenceValueString.length() == 0) {
      if (prefs != null) {
        boolean exists=false;
        int length=prefs.length();
        for (int i=0; i < length; i++) {
          if (prefs.getItemID(i) == itemID) {
            exists=true;
            break;
          }
        }
        if (exists) {
          if (length == 1) {
            data.remove(userID);
          }
 else {
            PreferenceArray newPrefs=new GenericUserPreferenceArray(length - 1);
            for (int i=0, j=0; i < length; i++, j++) {
              if (prefs.getItemID(i) == itemID) {
                j--;
              }
 else {
                newPrefs.set(j,prefs.get(i));
              }
            }
          }
        }
      }
    }
 else {
      float preferenceValue=Float.parseFloat(preferenceValueString);
      boolean exists=false;
      if (prefs != null) {
        for (int i=0; i < prefs.length(); i++) {
          if (prefs.getItemID(i) == itemID) {
            exists=true;
            prefs.setValue(i,preferenceValue);
            break;
          }
        }
      }
      if (!exists) {
        if (prefs == null) {
          prefs=new GenericUserPreferenceArray(1);
          ((FastByIDMap<PreferenceArray>)data).put(userID,prefs);
        }
 else {
          PreferenceArray newPrefs=new GenericUserPreferenceArray(prefs.length() + 1);
          for (int i=0, j=1; i < prefs.length(); i++, j++) {
            newPrefs.set(j,prefs.get(i));
          }
        }
        prefs.setUserID(0,userID);
        prefs.setItemID(0,itemID);
        prefs.setValue(0,preferenceValue);
      }
    }
  }
 else {
    Collection<Preference> prefs=(Collection<Preference>)maybePrefs;
    if (preferenceValueString.length() == 0) {
      if (prefs != null) {
        Iterator<Preference> prefsIterator=prefs.iterator();
        while (prefsIterator.hasNext()) {
          Preference pref=prefsIterator.next();
          if (pref.getItemID() == itemID) {
            prefsIterator.remove();
            break;
          }
        }
      }
    }
 else {
      float preferenceValue=Float.parseFloat(preferenceValueString);
      boolean exists=false;
      if (prefs != null) {
        for (        Preference pref : prefs) {
          if (pref.getItemID() == itemID) {
            exists=true;
            pref.setValue(preferenceValue);
            break;
          }
        }
      }
      if (!exists) {
        if (prefs == null) {
          prefs=new ArrayList<Preference>(2);
          ((FastByIDMap<Collection<Preference>>)data).put(userID,prefs);
        }
        prefs.add(new GenericPreference(userID,itemID,preferenceValue));
      }
    }
  }
}