Fix bug discovered in FGTP branch in which BlockInputStream returns -1 in cases where some data could be read,

but not all the data requested by the caller.
This commit is contained in:
Matt Hanna 2012-02-01 16:06:22 -05:00
parent a9671b73ca
commit 30b937d2af
1 changed files with 10 additions and 1 deletions

View File

@ -443,7 +443,16 @@ public class BlockInputStream extends SeekableStream implements BAMInputStream {
// }
// }
return eof() ? -1 : length-remaining;
// If any data was copied into the buffer, return the amount of data copied.
if(remaining < length)
return length - remaining;
// Otherwise, if at eof(), return -1.
else if(eof())
return -1;
// Otherwise, we must've hit a bug in the system.
throw new ReviewedStingException("BUG: read returned no data, but eof() reports false.");
}
public void close() {