Program: 140863
Project: 140863
Buggy source:
/** 
 * This will simply load the file by blocks of x rows, then sort them in-memory, and write the result to a bunch of temporary files that have to be merged later. Modified by M.Morsey I added a call to a function to normalize the _query, by renaming all _query variables, in order to make similar queries that use different variables counted as same _query.
 * @param file some flat  file
 * @param cmp the comparator to use
 * @param renameVariables should variables be renamed as ?var1 ,...
 * @return a list of temporary flat files
 * @throws IOException Signals that an IOException has occurred.
 */
public static List<File> sortInBatch(File file,Comparator<String> cmp,boolean renameVariables) throws IOException {
  List<File> files=new ArrayList<File>();
  BufferedReader fbr;
  long blocksize;
  if (renameVariables) {
    String normalizedFilename=normalizeFileVariables(file);
    File normalizedFile=new File(normalizedFilename);
    fbr=new BufferedReader(new FileReader(normalizedFile));
    blocksize=estimateBestSizeOfBlocks(normalizedFile);
  }
 else {
    fbr=new BufferedReader(new FileReader(file));
    blocksize=estimateBestSizeOfBlocks(file);
  }
  try {
    List<String> tmplist=new ArrayList<String>();
    String line="String_Node_Str";
    try {
      while (line != null) {
        long currentblocksize=0;
        while ((currentblocksize < blocksize) && ((line=fbr.readLine()) != null)) {
          tmplist.add(line);
          currentblocksize+=line.length() * 2;
        }
        files.add(sortAndSave(tmplist,cmp));
        tmplist.clear();
      }
    }
 catch (    EOFException oef) {
      if (tmplist.size() > 0) {
        files.add(sortAndSave(tmplist,cmp));
        tmplist.clear();
      }
    }
  }
  finally {
    fbr.close();
  }
  return files;
}

Fixed version (ground truth):
/** 
 * This will simply load the file by blocks of x rows, then sort them in-memory, and write the result to a bunch of temporary files that have to be merged later. Modified by M.Morsey I added a call to a function to normalize the _query, by renaming all _query variables, in order to make similar queries that use different variables counted as same _query.
 * @param file some flat  file
 * @param cmp the comparator to use
 * @param renameVariables should variables be renamed as ?var1 ,...
 * @return a list of temporary flat files
 * @throws IOException Signals that an IOException has occurred.
 */
public static List<File> sortInBatch(File file,Comparator<String> cmp,boolean renameVariables) throws IOException {
  List<File> files=new ArrayList<File>();
  BufferedReader fbr;
  long blocksize;
  if (renameVariables) {
    String normalizedFilename=normalizeFileVariables(file);
    File normalizedFile=new File(normalizedFilename);
    fbr=new BufferedReader(new FileReader(normalizedFile));
    blocksize=estimateBestSizeOfBlocks(normalizedFile);
  }
 else {
    fbr=new BufferedReader(new FileReader(file));
    blocksize=estimateBestSizeOfBlocks(file);
  }
  try {
    List<String> tmplist=new ArrayList<String>();
    String line="String_Node_Str";
    try {
      while (line != null) {
        long currentblocksize=0;
        while ((currentblocksize < blocksize) && ((line=fbr.readLine()) != null)) {
          if (line.trim().isEmpty()) {
            continue;
          }
          tmplist.add(line);
          currentblocksize+=line.length() * 2;
        }
        files.add(sortAndSave(tmplist,cmp));
        tmplist.clear();
      }
    }
 catch (    EOFException oef) {
      if (tmplist.size() > 0) {
        files.add(sortAndSave(tmplist,cmp));
        tmplist.clear();
      }
    }
  }
  finally {
    fbr.close();
  }
  return files;
}