Program: 50497
Project: 50497
Buggy source:
/** 
 * Run the map2text mode.
 * @throws java.io.IOException error reading / writing
 */
@Override public void execute() throws IOException {
  final AlignmentReader reader=new AlignmentReader(basename);
  reader.readHeader();
  final int numberOfReferences=reader.getNumberOfTargets();
  final DoubleIndexedIdentifier referenceIds=new DoubleIndexedIdentifier(reader.getTargetIdentifiers());
  reader.close();
  System.out.println(String.format("String_Node_Str",numberOfReferences));
  final IntSet referencesToProcess=new IntOpenHashSet();
  for (int referenceIndex=0; referenceIndex < numberOfReferences; referenceIndex++) {
    referencesToProcess.add(referenceIndex);
  }
  final AlignmentReader referenceReader=new AlignmentReader(inputFile);
  referenceReader.readHeader();
  final PrintWriter writer=outputFile == null ? new PrintWriter(System.out) : new PrintWriter(new FileWriter(outputFile));
  System.out.println("String_Node_Str");
  boolean hasReadIds=referenceReader.getQueryIdentifiers().size() > 0;
  DoubleIndexedIdentifier readIds=new DoubleIndexedIdentifier(referenceReader.getQueryIdentifiers());
  for (  final Alignments.AlignmentEntry alignmentEntry : referenceReader) {
    final int referenceIndex=alignmentEntry.getTargetIndex();
    final String referenceName=referenceIds.getId(referenceIndex).toString();
    if (referencesToProcess.contains(referenceIndex)) {
      final int startPosition=alignmentEntry.getPosition();
      final int alignmentLength=alignmentEntry.getQueryAlignedLength();
      for (int i=0; i < alignmentEntry.getMultiplicity(); ++i) {
        final int queryIndex=alignmentEntry.getQueryIndex();
        writer.write(String.format("String_Node_Str",hasReadIds ? readIds.getId(queryIndex) : Integer.toString(queryIndex),referenceName,alignmentEntry.getNumberOfIndels(),alignmentEntry.getNumberOfMismatches(),alignmentEntry.getScore(),startPosition,alignmentLength,alignmentEntry.getMatchingReverseStrand()));
      }
    }
  }
  writer.close();
  reader.close();
}

Fixed version (ground truth):
/** 
 * Run the map2text mode.
 * @throws java.io.IOException error reading / writing
 */
@Override public void execute() throws IOException {
  AlignmentReader reader=null;
  PrintWriter writer=null;
  try {
    reader=new AlignmentReader(basename);
    reader.readHeader();
    final int numberOfReferences=reader.getNumberOfTargets();
    final DoubleIndexedIdentifier referenceIds=new DoubleIndexedIdentifier(reader.getTargetIdentifiers());
    final int[] referenceLengths=reader.getTargetLength();
    System.out.println("String_Node_Str" + numberOfReferences + "String_Node_Str");
    final IntSet referencesToProcess=new IntOpenHashSet();
    for (int referenceIndex=0; referenceIndex < numberOfReferences; referenceIndex++) {
      referencesToProcess.add(referenceIndex);
    }
    System.out.println("String_Node_Str");
    writer=outputFile == null ? new PrintWriter(System.out) : new PrintWriter(outputFile);
    final boolean hasReadIds=reader.getQueryIdentifiers().size() > 0;
    final DoubleIndexedIdentifier readIds=new DoubleIndexedIdentifier(reader.getQueryIdentifiers());
    for (    final Alignments.AlignmentEntry alignmentEntry : reader) {
      final int referenceIndex=alignmentEntry.getTargetIndex();
      final String referenceName=referenceIds.getId(referenceIndex).toString();
      if (referencesToProcess.contains(referenceIndex)) {
        final int startPosition=alignmentEntry.getPosition();
        final int alignmentLength=alignmentEntry.getQueryAlignedLength();
        for (int i=0; i < alignmentEntry.getMultiplicity(); ++i) {
          final int queryIndex=alignmentEntry.getQueryIndex();
          writer.write(String.format("String_Node_Str",hasReadIds ? readIds.getId(queryIndex) : queryIndex,referenceName,alignmentEntry.getNumberOfIndels(),alignmentEntry.getNumberOfMismatches(),alignmentEntry.getScore(),startPosition,alignmentLength,alignmentEntry.getMatchingReverseStrand()));
        }
      }
    }
  }
  finally {
    IOUtils.closeQuietly(writer);
    if (reader != null) {
      reader.close();
    }
  }
}