Program: 50288
Project: 50288
Buggy source:
/** 
 * This version does a quick concat. It does NO filtering. It gathers no stats, but, will quickly concat multiple compact-reads files together using NIO. It should be noted that this method is >MUCH< faster. Copy all of the input files except the last MessageChunksWriter.DELIMITER_LENGTH bytes of the first n-1 input files and the entire last input file to the output file.
 * @throws IOException
 */
private void performQuickConcat() throws IOException {
  System.out.println("String_Node_Str");
  File outputFile=new File(outputFilename);
  if (outputFile.exists()) {
    System.err.println("String_Node_Str");
    return;
  }
  outputFile.createNewFile();
  FileChannel input=null;
  FileChannel output=null;
  long maxChunkSize=10 * 1024 * 1024;
  try {
    output=new FileOutputStream(outputFile).getChannel();
    int lastFileNumToCopy=inputFiles.size() - 1;
    int curFileNum=0;
    for (    final File inputFile : inputFiles) {
      System.out.printf("String_Node_Str",inputFile);
      input=new FileInputStream(inputFile).getChannel();
      long bytesToCopy=input.size();
      if (curFileNum++ < lastFileNumToCopy) {
        bytesToCopy-=(MessageChunksWriter.DELIMITER_LENGTH + MessageChunksWriter.SIZE_OF_MESSAGE_LENGTH);
      }
      long position=0;
      while (position < bytesToCopy) {
        long bytesToCopyThisTime=Math.min(maxChunkSize,bytesToCopy - position);
        position+=input.transferTo(position,bytesToCopyThisTime,output);
      }
      input.close();
      input=null;
    }
    System.out.printf("String_Node_Str",lastFileNumToCopy + 1);
  }
  finally {
    if (input != null) {
      input.close();
    }
    if (output != null) {
      output.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * This version does a quick concat. It does NO filtering. It gathers no stats, but, will quickly concat multiple compact-reads files together using NIO. It should be noted that this method is >MUCH< faster. Copy all of the input files except the last MessageChunksWriter.DELIMITER_LENGTH bytes of the first n-1 input files and the entire last input file to the output file.
 * @throws IOException
 */
private void performQuickConcat() throws IOException {
  System.out.println("String_Node_Str");
  File outputFile=new File(outputFilename);
  if (outputFile.exists()) {
    System.err.println("String_Node_Str");
    return;
  }
  outputFile.createNewFile();
  FileChannel input=null;
  FileChannel output=null;
  long maxChunkSize=10 * 1024 * 1024;
  try {
    output=new FileOutputStream(outputFile).getChannel();
    int lastFileNumToCopy=inputFiles.size() - 1;
    int curFileNum=0;
    for (    final File inputFile : inputFiles) {
      System.out.printf("String_Node_Str",inputFile);
      input=new FileInputStream(inputFile).getChannel();
      long bytesToCopy=input.size();
      if (curFileNum++ < lastFileNumToCopy) {
        bytesToCopy-=(MessageChunksWriter.DELIMITER_LENGTH + 1 + MessageChunksWriter.SIZE_OF_MESSAGE_LENGTH);
      }
      long position=0;
      while (position < bytesToCopy) {
        long bytesToCopyThisTime=Math.min(maxChunkSize,bytesToCopy - position);
        position+=input.transferTo(position,bytesToCopyThisTime,output);
      }
      input.close();
      input=null;
    }
    System.out.printf("String_Node_Str",lastFileNumToCopy + 1);
  }
  finally {
    if (input != null) {
      input.close();
    }
    if (output != null) {
      output.close();
    }
  }
}