|
@@ -269,14 +269,20 @@ public final class FSImageFormatProtobuf {
|
|
|
String compressionCodec)
|
|
|
throws IOException {
|
|
|
FileInputStream fin = new FileInputStream(filename);
|
|
|
- FileChannel channel = fin.getChannel();
|
|
|
- channel.position(section.getOffset());
|
|
|
- InputStream in = new BufferedInputStream(new LimitInputStream(fin,
|
|
|
- section.getLength()));
|
|
|
+ try {
|
|
|
|
|
|
- in = FSImageUtil.wrapInputStreamForCompression(conf,
|
|
|
- compressionCodec, in);
|
|
|
- return in;
|
|
|
+ FileChannel channel = fin.getChannel();
|
|
|
+ channel.position(section.getOffset());
|
|
|
+ InputStream in = new BufferedInputStream(new LimitInputStream(fin,
|
|
|
+ section.getLength()));
|
|
|
+
|
|
|
+ in = FSImageUtil.wrapInputStreamForCompression(conf,
|
|
|
+ compressionCodec, in);
|
|
|
+ return in;
|
|
|
+ } catch (IOException e) {
|
|
|
+ fin.close();
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|