samtools/htsjdk — pull request #20 by BeatWolf (2014-05-23 12:16:16+00:00)
Title: Fix nullpointer exception when BAMFileSpan is null

When index caching is enabled there is sometimes a NullPointer Exception in SAMFileSpan.merge

The reason is that the BAMFileSpan array passed as a parameter can contain null elements.

You can see creation of that array in:

BAMFileReader.createIndexIterator (line 729)

You can see a call to getSpanOverlapping which creates those BAMFileSpan objects.

a quick look at one of its implementations, for example:
CachingBAMFileIndex.getSpanOverlapping

shows that there are several cases where null can be returned.

This patch fixes the issue.