GATKBAMIndex now passes unit test! Problem was that SeekableBufferedStream seems to have a bug: it will read beyond the end of a file if asked to.
This commit is contained in:
parent
002ce9c1d5
commit
6ed9eb3da9
|
|
@ -359,7 +359,10 @@ public class GATKBAMIndex {
|
|||
int bytesExpected = buffer.limit();
|
||||
//BufferedInputStream cannot read directly into a byte buffer, so we read into an array
|
||||
//and put the result into the bytebuffer after the if statement.
|
||||
int bytesRead = bufferedStream.read(byteArray,0,bytesExpected);
|
||||
|
||||
//SeekableBufferedStream is evil, it will "read" beyond the end of the file if you let it!
|
||||
final int bytesToRead = (int) Math.min(bufferedStream.length() - bufferedStream.position(), bytesExpected); //min of int and long will definitely be castable to an int.
|
||||
int bytesRead = bufferedStream.read(byteArray,0,bytesToRead);
|
||||
|
||||
// We have a rigid expectation here to read in exactly the number of bytes we've limited
|
||||
// our buffer to -- if we read in fewer bytes than this, or encounter EOF (-1), the index
|
||||
|
|
|
|||
Loading…
Reference in New Issue