samtools / htsjdk

A Java API for high-throughput sequencing data (HTS) formats.
http://samtools.github.io/htsjdk/
283 stars 242 forks source link

[SpotBugs] contentId isn't initialized in htsjdk.samtools.cram.structure.block.ExternalBlock.getContentId() when invoked from constructor for superclass #1279

Closed tomwhite closed 5 years ago

tomwhite commented 5 years ago

This looks like a real bug in CRAM. /cc @jmthibault79, @cmnbroad

See https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#ur-uninitialized-read-of-field-method-called-from-constructor-of-superclass-ur-uninit-read-called-from-super-constructor

Part of #1267

Report:

In class htsjdk.samtools.cram.structure.block.ExternalBlock
In method htsjdk.samtools.cram.structure.block.ExternalBlock.getContentId()
Field htsjdk.samtools.cram.structure.block.ExternalBlock.contentId
Superclass constructor is new htsjdk.samtools.cram.structure.block.Block(BlockCompressionMethod, BlockContentType, byte[], int)
Call from superclass constructor at Block.java:[line 86]
Constructor is new htsjdk.samtools.cram.structure.block.ExternalBlock(BlockCompressionMethod, int, byte[], int)
Field set (too late) at ExternalBlock.java:[line 26]
At ExternalBlock.java:[line 31]