Program: 30665
Project: 30665
Buggy source:
/** 
 * Record any index information for a given BAM record
 * @param rec The BAM record
 */
public void processAlignment(final SAMRecord rec){
  indexStats.recordMetaData(rec);
  final int alignmentStart=rec.getAlignmentStart();
  if (alignmentStart == SAMRecord.NO_ALIGNMENT_START) {
    return;
  }
  final int reference=rec.getReferenceIndex();
  if (reference != currentReference) {
    throw new SAMException("String_Node_Str" + reference + "String_Node_Str"+ currentReference+ "String_Node_Str"+ rec);
  }
  final Integer binNumber=rec.getIndexingBin();
  final int binNum=binNumber == null ? rec.computeIndexingBin() : binNumber;
  if (bins == null) {
    final SAMSequenceRecord seq=bamHeader.getSequence(reference);
    if (seq == null) {
      bins=new Bin[MAX_BINS + 1];
    }
 else {
      bins=new Bin[AbstractBAMFileIndex.getMaxBinNumberForSequenceLength(seq.getSequenceLength()) + 1];
    }
  }
  final Bin bin;
  if (bins[binNum] != null) {
    bin=bins[binNum];
  }
 else {
    bin=new Bin(reference,binNum);
    bins[binNum]=bin;
    binsSeen++;
  }
  final SAMFileSource source=rec.getFileSource();
  if (source == null) {
    throw new SAMException("String_Node_Str" + rec);
  }
  final Chunk newChunk=((BAMFileSpan)source.getFilePointer()).getSingleChunk();
  final long chunkStart=newChunk.getChunkStart();
  final long chunkEnd=newChunk.getChunkEnd();
  final List<Chunk> oldChunks=bin.getChunkList();
  if (oldChunks == null) {
    bin.addInitialChunk(newChunk);
  }
 else {
    final Chunk lastChunk=bin.getLastChunk();
    if (BlockCompressedFilePointerUtil.areInSameOrAdjacentBlocks(lastChunk.getChunkEnd(),chunkStart)) {
      lastChunk.setChunkEnd(chunkEnd);
    }
 else {
      oldChunks.add(newChunk);
      bin.setLastChunk(newChunk);
    }
  }
  final int alignmentEnd=rec.getAlignmentEnd();
  int startWindow=LinearIndex.convertToLinearIndexOffset(alignmentStart);
  final int endWindow;
  if (alignmentEnd == SAMRecord.NO_ALIGNMENT_START) {
    startWindow=LinearIndex.convertToLinearIndexOffset(alignmentStart - 1);
    endWindow=startWindow;
  }
 else {
    endWindow=LinearIndex.convertToLinearIndexOffset(alignmentEnd);
  }
  if (endWindow > largestIndexSeen) {
    largestIndexSeen=endWindow;
  }
  for (int win=startWindow; win <= endWindow; win++) {
    if (index[win] == 0 || chunkStart < index[win]) {
      index[win]=chunkStart;
    }
  }
}

Fixed version (ground truth):
/** 
 * Record any index information for a given BAM record
 * @param rec The BAM record
 */
public void processAlignment(final SAMRecord rec){
  indexStats.recordMetaData(rec);
  final int alignmentStart=rec.getAlignmentStart();
  if (alignmentStart == SAMRecord.NO_ALIGNMENT_START) {
    return;
  }
  final int reference=rec.getReferenceIndex();
  if (reference != currentReference) {
    throw new SAMException("String_Node_Str" + reference + "String_Node_Str"+ currentReference+ "String_Node_Str"+ rec);
  }
  final Integer binNumber=rec.getIndexingBin();
  final int binNum=binNumber == null ? rec.computeIndexingBin() : binNumber;
  if (bins == null) {
    final SAMSequenceRecord seq=bamHeader.getSequence(reference);
    if (seq == null) {
      bins=new Bin[MAX_BINS + 1];
    }
 else {
      bins=new Bin[AbstractBAMFileIndex.getMaxBinNumberForSequenceLength(seq.getSequenceLength()) + 1];
    }
  }
  final Bin bin;
  if (bins[binNum] != null) {
    bin=bins[binNum];
  }
 else {
    bin=new Bin(reference,binNum);
    bins[binNum]=bin;
    binsSeen++;
  }
  final SAMFileSource source=rec.getFileSource();
  if (source == null) {
    throw new SAMException("String_Node_Str" + rec);
  }
  final Chunk newChunk=((BAMFileSpan)source.getFilePointer()).getSingleChunk();
  final long chunkStart=newChunk.getChunkStart();
  final long chunkEnd=newChunk.getChunkEnd();
  final List<Chunk> oldChunks=bin.getChunkList();
  if (!bin.containsChunks()) {
    bin.addInitialChunk(newChunk);
  }
 else {
    final Chunk lastChunk=bin.getLastChunk();
    if (BlockCompressedFilePointerUtil.areInSameOrAdjacentBlocks(lastChunk.getChunkEnd(),chunkStart)) {
      lastChunk.setChunkEnd(chunkEnd);
    }
 else {
      oldChunks.add(newChunk);
      bin.setLastChunk(newChunk);
    }
  }
  final int alignmentEnd=rec.getAlignmentEnd();
  int startWindow=LinearIndex.convertToLinearIndexOffset(alignmentStart);
  final int endWindow;
  if (alignmentEnd == SAMRecord.NO_ALIGNMENT_START) {
    startWindow=LinearIndex.convertToLinearIndexOffset(alignmentStart - 1);
    endWindow=startWindow;
  }
 else {
    endWindow=LinearIndex.convertToLinearIndexOffset(alignmentEnd);
  }
  if (endWindow > largestIndexSeen) {
    largestIndexSeen=endWindow;
  }
  for (int win=startWindow; win <= endWindow; win++) {
    if (index[win] == 0 || chunkStart < index[win]) {
      index[win]=chunkStart;
    }
  }
}