Program: 146523
Project: 146523
Buggy source:
/** 
 * Reads the temporary files created by splitChunks method and merges them in a sorted manner into the output stream.
 * @param os
 * @throws IOException
 */
public void mergeChunks() throws IOException {
  OutputStream os=new FileOutputStream(this.tempFile.toFile());
  Map<StringWrapper,BufferedReader> map=new HashMap<>();
  List<BufferedReader> readers=new ArrayList<>();
  BufferedWriter writer=null;
  try {
    writer=new BufferedWriter(new OutputStreamWriter(os));
    for (int i=0; i < outputs.size(); i++) {
      BufferedReader reader=new BufferedReader(new FileReader(outputs.get(i)));
      readers.add(reader);
      String line=reader.readLine();
      if (line != null) {
        map.put(new StringWrapper(line.split(delimiter),colOrder),readers.get(i));
      }
    }
    List<StringWrapper> sorted=new LinkedList<>(map.keySet());
    while (map.size() > 0) {
      Collections.sort(sorted);
      StringWrapper line=sorted.remove(0);
      writer.write(StrArray.Join(line.string,delimiter));
      writer.write("String_Node_Str");
      BufferedReader reader=map.remove(line);
      String nextLine=reader.readLine();
      if (nextLine != null) {
        StringWrapper sw=new StringWrapper(nextLine.split(delimiter),colOrder);
        map.put(sw,reader);
        sorted.add(sw);
      }
    }
  }
 catch (  IOException io) {
    log.log(Level.SEVERE,"String_Node_Str" + readers.size() + "String_Node_Str"+ os.toString(),io);
  }
 finally {
    for (int i=0; i < readers.size(); i++) {
      try {
        readers.get(i).close();
      }
 catch (      Exception e) {
      }
    }
    for (int i=0; i < outputs.size(); i++) {
      outputs.get(i).delete();
    }
    try {
      writer.close();
    }
 catch (    Exception e) {
    }
  }
  os.close();
}

Fixed version (ground truth):
/** 
 * Reads the temporary files created by splitChunks method and merges them in a sorted manner into the output stream.
 * @param os
 * @throws IOException
 */
public void mergeChunks() throws IOException {
  OutputStream os=new FileOutputStream(this.tempFile.toFile());
  Map<StringWrapper,BufferedReader> map=new HashMap<>();
  List<BufferedReader> readers=new ArrayList<>();
  BufferedWriter writer=null;
  try {
    writer=new BufferedWriter(new OutputStreamWriter(os));
    for (int i=0; i < outputs.size(); i++) {
      BufferedReader reader=new BufferedReader(new FileReader(outputs.get(i)));
      String line=reader.readLine();
      if (line != null) {
        readers.add(reader);
        map.put(new StringWrapper(line.split(delimiter),colOrder),readers.get(readers.size() - 1));
      }
    }
    List<StringWrapper> sorted=new LinkedList<>(map.keySet());
    while (map.size() > 0) {
      Collections.sort(sorted);
      StringWrapper line=sorted.remove(0);
      writer.write(StrArray.Join(line.string,delimiter));
      writer.write("String_Node_Str");
      BufferedReader reader=map.remove(line);
      String nextLine=reader.readLine();
      if (nextLine != null) {
        StringWrapper sw=new StringWrapper(nextLine.split(delimiter),colOrder);
        map.put(sw,reader);
        sorted.add(sw);
      }
    }
  }
 catch (  IOException io) {
    log.log(Level.SEVERE,"String_Node_Str" + readers.size() + "String_Node_Str"+ os.toString(),io);
  }
 finally {
    for (int i=0; i < readers.size(); i++) {
      try {
        readers.get(i).close();
      }
 catch (      Exception e) {
        log.log(Level.SEVERE,"String_Node_Str" + readers.get(i).toString());
      }
    }
    for (int i=0; i < outputs.size(); i++) {
      outputs.get(i).delete();
    }
    try {
      writer.close();
    }
 catch (    Exception e) {
    }
  }
  os.close();
}