Program: 13757
Project: 13757
Buggy source:
protected void PicardPreprocess(Context context,PreprocessingTools tools,SAMRecordIterator input,String output) throws InterruptedException, QualityException {
  outHeader=header.clone();
  outHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);
  String tmpOut1=tmpFileBase + "String_Node_Str";
  String tmpOut2=tmpFileBase + "String_Node_Str";
  String tmpOut3=tmpFileBase + "String_Node_Str";
  String tmpMetrics=tmpFileBase + "String_Node_Str";
  SAMFileWriterFactory factory=new SAMFileWriterFactory();
  SAMFileWriter writer=factory.makeBAMWriter(outHeader,true,new File(tmpOut1));
  long startTime=System.currentTimeMillis();
  int count=0;
  SAMRecord sam;
  while (input.hasNext()) {
    sam=input.next();
    writer.addAlignment(sam);
    count++;
  }
  int reads=input.getCount();
  writer.close();
  context.getCounter(HalvadeCounters.IN_PREP_READS).increment(reads);
  long estimatedTime=System.currentTimeMillis() - startTime;
  context.getCounter(HalvadeCounters.TIME_HADOOP_SAMTOBAM).increment(estimatedTime);
  Logger.DEBUG("String_Node_Str" + count + "String_Node_Str"+ estimatedTime / 1000);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runCleanSam(tmpOut1,tmpOut2);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runMarkDuplicates(tmpOut2,tmpOut3,tmpMetrics);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runAddOrReplaceReadGroups(tmpOut3,output,RGID,RGLB,RGPL,RGPU,RGSM);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runBuildBamIndex(output);
  estimatedTime=System.currentTimeMillis() - startTime;
  Logger.DEBUG("String_Node_Str" + estimatedTime / 1000);
  HalvadeFileUtils.removeLocalFile(keep,tmpMetrics,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut1,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut2,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut3,context,HalvadeCounters.FOUT_GATK_TMP);
}

Fixed version (ground truth):
protected void PicardPreprocess(Context context,PreprocessingTools tools,SAMRecordIterator input,String output) throws InterruptedException, QualityException {
  outHeader=header.clone();
  outHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);
  String tmpOut1=tmpFileBase + "String_Node_Str";
  String tmpOut2=tmpFileBase + "String_Node_Str";
  String tmpOut3=tmpFileBase + "String_Node_Str";
  String tmpMetrics=tmpFileBase + "String_Node_Str";
  SAMFileWriterFactory factory=new SAMFileWriterFactory();
  outHeader.addReadGroup(bamrg);
  SAMFileWriter writer=factory.makeBAMWriter(outHeader,true,new File(tmpOut1));
  long startTime=System.currentTimeMillis();
  int count=0;
  SAMRecord sam;
  while (input.hasNext()) {
    sam=input.next();
    writer.addAlignment(sam);
    count++;
  }
  int reads=input.getCount();
  writer.close();
  context.getCounter(HalvadeCounters.IN_PREP_READS).increment(reads);
  long estimatedTime=System.currentTimeMillis() - startTime;
  context.getCounter(HalvadeCounters.TIME_HADOOP_SAMTOBAM).increment(estimatedTime);
  Logger.DEBUG("String_Node_Str" + count + "String_Node_Str"+ estimatedTime / 1000);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runCleanSam(tmpOut1,tmpOut2);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runMarkDuplicates(tmpOut2,tmpOut3,tmpMetrics);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runAddOrReplaceReadGroups(tmpOut3,output,RGID,RGLB,RGPL,RGPU,RGSM);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runBuildBamIndex(output);
  estimatedTime=System.currentTimeMillis() - startTime;
  Logger.DEBUG("String_Node_Str" + estimatedTime / 1000);
  HalvadeFileUtils.removeLocalFile(keep,tmpMetrics,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut1,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut2,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut3,context,HalvadeCounters.FOUT_GATK_TMP);
}