HBASE-1809 NPE thrown in BoundedRangeFileInputStream

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@810301 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-09-01 23:16:14 +00:00
parent dea3c1207c
commit 231e0c0043
2 changed files with 21 additions and 12 deletions

View File

@ -362,6 +362,7 @@ Release 0.20.0 - Unreleased
hudson too
HBASE-1780 HTable.flushCommits clears write buffer in finally clause
HBASE-1784 Missing rows after medium intensity insert
HBASE-1809 NPE thrown in BoundedRangeFileInputStream
IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -967,18 +967,26 @@ public class HFile {
private ByteBuffer decompress(final long offset, final int compressedSize,
final int decompressedSize)
throws IOException {
Decompressor decompressor = this.compressAlgo.getDecompressor();
// My guess is that the bounded range fis is needed to stop the
// decompressor reading into next block -- IIRC, it just grabs a
// bunch of data w/o regard to whether decompressor is coming to end of a
// decompression.
InputStream is = this.compressAlgo.createDecompressionStream(
new BoundedRangeFileInputStream(this.istream, offset, compressedSize),
decompressor, 0);
ByteBuffer buf = ByteBuffer.allocate(decompressedSize);
IOUtils.readFully(is, buf.array(), 0, buf.capacity());
is.close();
this.compressAlgo.returnDecompressor(decompressor);
Decompressor decompressor = null;
try {
decompressor = this.compressAlgo.getDecompressor();
// My guess is that the bounded range fis is needed to stop the
// decompressor reading into next block -- IIRC, it just grabs a
// bunch of data w/o regard to whether decompressor is coming to end of a
// decompression.
InputStream is = this.compressAlgo.createDecompressionStream(
new BoundedRangeFileInputStream(this.istream, offset, compressedSize),
decompressor, 0);
ByteBuffer buf = ByteBuffer.allocate(decompressedSize);
IOUtils.readFully(is, buf.array(), 0, buf.capacity());
is.close();
} finally {
if (null != decompressor) {
this.compressAlgo.returnDecompressor(decompressor);
}
}
return buf;
}