Program: 141054
Project: 141054
Buggy source:
/** 
 * Convert SAM file to FASTQ
 * @param samDataFile input SAM file
 * @param fastqFile output FASTQ file
 * @param reporter reporter
 * @param tmpDir temporary directory
 * @throws IOException if an error occurs
 */
private static void writeConvert(final File samDataFile,final DataFile fastqDataFile1,final DataFile fastqDataFile2,final Reporter reporter) throws IOException {
  final SamReader samReader=SamReaderFactory.makeDefault().open(SamInputResource.of(new FileInputStream(samDataFile)));
  final FastqWriter fastqWriter1=new FastqWriter(fastqDataFile1.create());
  final FastqWriter fastqWriter2=fastqDataFile2 == null ? null : new FastqWriter(fastqDataFile2.create());
  int id=0;
  String seq1=null;
  String seq2=null;
  String qual1=null;
  String qual2=null;
  String currentRecordId=null;
  for (  final SAMRecord samRecord : samReader) {
    if (currentRecordId != null && !currentRecordId.equals(samRecord.getReadName())) {
      id++;
      reporter.incrCounter(COUNTER_GROUP,"String_Node_Str",1);
      writeFastq(id,fastqWriter1,fastqWriter2,currentRecordId,seq1,qual1,seq2,qual2);
      seq1=seq2=qual1=qual2=null;
    }
    if (samRecord.getReadPairedFlag() && !samRecord.getFirstOfPairFlag()) {
      seq2=samRecord.getReadString();
      qual2=samRecord.getBaseQualityString();
    }
 else {
      seq1=samRecord.getReadString();
      qual1=samRecord.getBaseQualityString();
    }
    currentRecordId=samRecord.getReadName();
  }
  if (seq1 != null && seq2 != null) {
    id++;
    reporter.incrCounter(COUNTER_GROUP,"String_Node_Str",1);
    writeFastq(id,fastqWriter1,fastqWriter2,currentRecordId,seq1,qual1,seq2,qual2);
  }
  samReader.close();
  fastqWriter1.close();
  if (fastqWriter2 != null) {
    fastqWriter2.close();
  }
}

Fixed version (ground truth):
/** 
 * Convert SAM file to FASTQ
 * @param samDataFile input SAM file
 * @param fastqDataFile1 output FASTQ file 1
 * @param fastqDataFile2 output FASTQ file 2
 * @param reporter reporter
 * @throws IOException if an error occurs
 */
private static void writeConvert(final File samDataFile,final DataFile fastqDataFile1,final DataFile fastqDataFile2,final Reporter reporter) throws IOException {
  final SamReader samReader=SamReaderFactory.makeDefault().open(SamInputResource.of(new FileInputStream(samDataFile)));
  final FastqWriter fastqWriter1=new FastqWriter(fastqDataFile1.create());
  final FastqWriter fastqWriter2=fastqDataFile2 == null ? null : new FastqWriter(fastqDataFile2.create());
  int id=0;
  String seq1=null;
  String seq2=null;
  String qual1=null;
  String qual2=null;
  String currentRecordId=null;
  for (  final SAMRecord samRecord : samReader) {
    if (currentRecordId != null && !currentRecordId.equals(samRecord.getReadName())) {
      id++;
      reporter.incrCounter(COUNTER_GROUP,"String_Node_Str",1);
      writeFastq(id,fastqWriter1,fastqWriter2,currentRecordId,seq1,qual1,seq2,qual2);
      seq1=seq2=qual1=qual2=null;
    }
    if (samRecord.getReadPairedFlag() && !samRecord.getFirstOfPairFlag()) {
      seq2=samRecord.getReadString();
      qual2=samRecord.getBaseQualityString();
    }
 else {
      seq1=samRecord.getReadString();
      qual1=samRecord.getBaseQualityString();
    }
    currentRecordId=samRecord.getReadName();
  }
  if (seq1 != null && seq2 != null) {
    id++;
    reporter.incrCounter(COUNTER_GROUP,"String_Node_Str",1);
    writeFastq(id,fastqWriter1,fastqWriter2,currentRecordId,seq1,qual1,seq2,qual2);
  }
  samReader.close();
  fastqWriter1.close();
  if (fastqWriter2 != null) {
    fastqWriter2.close();
  }
}