Buggy code:
public class IndexedFastaSequenceFile extends AbstractFastaSequenceFile implements Closeable { private final SeekableByteChannel channel ; private final FastaSequenceIndex index ; private Iterator < FastaSequenceIndexEntry > indexIterator ; public IndexedFastaSequenceFile ( final File file , final FastaSequenceIndex index ) { } public IndexedFastaSequenceFile ( final File file ) throws FileNotFoundException { } public IndexedFastaSequenceFile ( final Path path , final FastaSequenceIndex index ) { } public IndexedFastaSequenceFile ( final Path path ) throws FileNotFoundException { } public boolean isIndexed ( ) { } private static File findFastaIndex ( File fastaFile ) { } private static File getFastaIndexFileName ( File fastaFile ) { } private static File findRequiredFastaIndexFile ( File fastaFile ) throws FileNotFoundException { } public static boolean canCreateIndexedFastaReader ( final File fastaFile ) { } private static Path findFastaIndex ( Path fastaFile ) { } private static Path getFastaIndexFileName ( Path fastaFile ) { } private static Path findRequiredFastaIndexFile ( Path fastaFile ) throws FileNotFoundException { } public static boolean canCreateIndexedFastaReader ( final Path fastaFile ) { } protected static void sanityCheckDictionaryAgainstIndex ( final String fastaFile , final SAMSequenceDictionary sequenceDictionary , final FastaSequenceIndex index ) { } public SAMSequenceDictionary getSequenceDictionary ( ) { } public ReferenceSequence getSequence ( String contig ) { } public ReferenceSequence getSubsequenceAt ( String contig , long start , long stop ) { if ( start > ( stop + 1 ) ) throw new SAMException ( String . format ( "Malformed<seq2seq4repair_space>query;<seq2seq4repair_space>start<seq2seq4repair_space>point<seq2seq4repair_space>%d<seq2seq4repair_space>lies<seq2seq4repair_space>after<seq2seq4repair_space>end<seq2seq4repair_space>point<seq2seq4repair_space>%d" , start , stop ) ) ; FastaSequenceIndexEntry indexEntry = index . getIndexEntry ( contig ) ; if ( stop > ( indexEntry . getSize ( ) ) ) throw new SAMException ( "Query<seq2seq4repair_space>asks<seq2seq4repair_space>for<seq2seq4repair_space>data<seq2seq4repair_space>past<seq2seq4repair_space>end<seq2seq4repair_space>of<seq2seq4repair_space>contig" ) ; int length = ( ( int ) ( ( stop - start ) + 1 ) ) ; byte [ ] target = new byte [ length ] ; ByteBuffer targetBuffer = ByteBuffer . wrap ( target ) ; final int basesPerLine = indexEntry . getBasesPerLine ( ) ; final int bytesPerLine = indexEntry . getBytesPerLine ( ) ; final int terminatorLength = bytesPerLine - basesPerLine ; long startOffset = ( ( ( start - 1 ) // basesPerLine ) * bytesPerLine ) + ( ( start - 1 ) % basesPerLine ) ; <START_BUG> final long minBufferSize = Math . min ( ( ( long ) ( NON_ZERO_BUFFER_SIZE ) ) , ( ( ( long ) ( ( length % basesPerLine ) + 2 ) ) * ( ( long ) ( bytesPerLine ) ) ) ) ; <END_BUG> if ( minBufferSize > ( Integer . MAX_VALUE ) ) throw new SAMException ( ( "Buffer<seq2seq4repair_space>is<seq2seq4repair_space>too<seq2seq4repair_space>large:<seq2seq4repair_space>" + minBufferSize ) ) ; final ByteBuffer channelBuffer = ByteBuffer . allocate ( ( ( int ) ( minBufferSize ) ) ) ; while ( ( targetBuffer . position ( ) ) < length ) { startOffset += Math . max ( ( ( int ) ( ( ( startOffset % bytesPerLine ) - basesPerLine ) + 1 ) ) , 0 ) ; try { startOffset += IndexedFastaSequenceFile . readFromPosition ( channel , channelBuffer , ( ( indexEntry . getLocation ( ) ) + startOffset ) ) ; } catch ( IOException ex ) { throw new SAMException ( ( ( ( ( ( ( ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>load<seq2seq4repair_space>" + contig ) + "(" ) + start ) + ",<seq2seq4repair_space>" ) + stop ) + ")<seq2seq4repair_space>from<seq2seq4repair_space>" ) + ( getAbsolutePath ( ) ) ) , ex ) ; } channelBuffer . flip ( ) ; final int positionInContig = ( ( ( int ) ( start ) ) - 1 ) + ( targetBuffer . position ( ) ) ; final int nextBaseSpan = Math . min ( ( basesPerLine - ( positionInContig % basesPerLine ) ) , ( length - ( targetBuffer . position ( ) ) ) ) ; int bytesToTransfer = Math . min ( nextBaseSpan , channelBuffer . capacity ( ) ) ; channelBuffer . limit ( ( ( channelBuffer . position ( ) ) + bytesToTransfer ) ) ; while ( channelBuffer . hasRemaining ( ) ) { targetBuffer . put ( channelBuffer ) ; bytesToTransfer = Math . min ( basesPerLine , ( length - ( targetBuffer . position ( ) ) ) ) ; channelBuffer . limit ( Math . min ( ( ( ( channelBuffer . position ( ) ) + bytesToTransfer ) + terminatorLength ) , channelBuffer . capacity ( ) ) ) ; channelBuffer . position ( Math . min ( ( ( channelBuffer . position ( ) ) + terminatorLength ) , channelBuffer . capacity ( ) ) ) ; } channelBuffer . flip ( ) ; } return new ReferenceSequence ( contig , indexEntry . getSequenceIndex ( ) , target ) ; } private static int readFromPosition ( final SeekableByteChannel channel , final ByteBuffer buffer , long position ) throws IOException { } public ReferenceSequence nextSequence ( ) { } public void reset ( ) { } public String toString ( ) { } @ Override public void close ( ) throws IOException { } }

Fix:
final long minBufferSize = Math . min ( ( ( long ) ( NON_ZERO_BUFFER_SIZE ) ) , ( ( ( long ) ( ( length // basesPerLine ) + 2 ) ) * ( ( long ) ( bytesPerLine ) ) ) ) ;