Permalink
Browse files

incoporated code review comments.

  • Loading branch information...
1 parent 793a132 commit 70d6a072ac085788817b8d0d266ee510ec48618f @yuxutw yuxutw committed Apr 24, 2012
@@ -87,14 +87,9 @@ public CompressionInputStream createInputStream(InputStream in,
@Override
public CompressionInputStream createInputStream(InputStream in) throws IOException {
- // Ensure native-lzo library is loaded & initialized
- if (!isNativeLzoLoaded(getConf())) {
- throw new RuntimeException("native-lzo library not available");
- }
- /*create a decompressor and tell LzoInputStream to reuse it
+ /*create a decompressor and tell LzoInputStream to reuse it
* (return it to the pool when LzoInputStream is closed.
*/
-
return new LzopInputStream(in, CodecPool.getDecompressor(this),
getConf().getInt(LZO_BUFFER_SIZE_KEY, DEFAULT_LZO_BUFFER_SIZE), true);
}
@@ -339,14 +339,15 @@ public void close() throws IOException {
decompressor.decompress(b, 0, b.length);
}
super.close();
- if(reuseDecompressor)
- CodecPool.returnDecompressor(decompressor);
try {
verifyChecksums();
} catch (IOException e) {
// LZO requires that each file ends with 4 trailing zeroes. If we are here,
// the file didn't. It's not critical, though, so log and eat it in this case.
LOG.warn("Incorrect LZO file format: file did not end with four trailing zeroes.", e);
+ } finally{
+ if(reuseDecompressor)
+ CodecPool.returnDecompressor(decompressor);
}
}
}

0 comments on commit 70d6a07

Please sign in to comment.