Program: 109360
Project: 109360
Buggy source:
private Multimap<Long,RecommendedItem> split(File dataDir,File trainingFile,double trainPercentage,double evaluationPercentage,RescorerProvider provider) throws IOException {
  Multimap<Long,RecommendedItem> data=readDataFile(dataDir,evaluationPercentage,provider);
  log.info("String_Node_Str",data.size());
  Multimap<Long,RecommendedItem> testData=ArrayListMultimap.create();
  Writer trainingOut=IOUtils.buildGZIPWriter(trainingFile);
  try {
    Iterator<Map.Entry<Long,Collection<RecommendedItem>>> it=data.asMap().entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<Long,Collection<RecommendedItem>> entry=it.next();
      long userID=entry.getKey();
      List<RecommendedItem> userPrefs=Lists.newArrayList(entry.getValue());
      it.remove();
      if (isSplitTestByPrefValue()) {
        Collections.sort(userPrefs,ByValueAscComparator.INSTANCE);
      }
      int numTraining=FastMath.max(1,(int)(trainPercentage * userPrefs.size()));
      for (      RecommendedItem rec : userPrefs.subList(0,numTraining)) {
        trainingOut.write(Long.toString(userID));
        trainingOut.write(DELIMITER);
        trainingOut.write(Long.toString(rec.getItemID()));
        trainingOut.write(DELIMITER);
        trainingOut.write(Float.toString(rec.getValue()));
        trainingOut.write('\n');
      }
      for (      RecommendedItem rec : userPrefs.subList(numTraining,userPrefs.size())) {
        testData.put(userID,rec);
      }
    }
  }
  finally {
    trainingOut.close();
  }
  log.info("String_Node_Str",testData.size());
  return testData;
}

Fixed version (ground truth):
private Multimap<Long,RecommendedItem> split(File dataDir,File trainingFile,double trainPercentage,double evaluationPercentage,RescorerProvider provider) throws IOException {
  DataFileContents dataFileContents=readDataFile(dataDir,evaluationPercentage,provider);
  Multimap<Long,RecommendedItem> data=dataFileContents.getData();
  log.info("String_Node_Str",data.size());
  Multimap<Long,RecommendedItem> testData=ArrayListMultimap.create();
  Writer trainingOut=IOUtils.buildGZIPWriter(trainingFile);
  try {
    Iterator<Map.Entry<Long,Collection<RecommendedItem>>> it=data.asMap().entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<Long,Collection<RecommendedItem>> entry=it.next();
      long userID=entry.getKey();
      List<RecommendedItem> userPrefs=Lists.newArrayList(entry.getValue());
      it.remove();
      if (isSplitTestByPrefValue()) {
        Collections.sort(userPrefs,ByValueAscComparator.INSTANCE);
      }
      int numTraining=FastMath.max(1,(int)(trainPercentage * userPrefs.size()));
      for (      RecommendedItem rec : userPrefs.subList(0,numTraining)) {
        trainingOut.write(Long.toString(userID));
        trainingOut.write(DELIMITER);
        trainingOut.write(Long.toString(rec.getItemID()));
        trainingOut.write(DELIMITER);
        trainingOut.write(Float.toString(rec.getValue()));
        trainingOut.write('\n');
      }
      for (      RecommendedItem rec : userPrefs.subList(numTraining,userPrefs.size())) {
        testData.put(userID,rec);
      }
    }
    for (    Map.Entry<String,RecommendedItem> entry : dataFileContents.getItemTags().entries()) {
      trainingOut.write(entry.getKey());
      trainingOut.write(DELIMITER);
      trainingOut.write(Long.toString(entry.getValue().getItemID()));
      trainingOut.write(DELIMITER);
      trainingOut.write(Float.toString(entry.getValue().getValue()));
      trainingOut.write('\n');
    }
    for (    Map.Entry<String,RecommendedItem> entry : dataFileContents.getUserTags().entries()) {
      trainingOut.write(Long.toString(entry.getValue().getItemID()));
      trainingOut.write(DELIMITER);
      trainingOut.write(entry.getKey());
      trainingOut.write(DELIMITER);
      trainingOut.write(Float.toString(entry.getValue().getValue()));
      trainingOut.write('\n');
    }
  }
  finally {
    trainingOut.close();
  }
  log.info("String_Node_Str",testData.size());
  return testData;
}