HDFS-15791. Possible Resource Leak in FSImageFormatProtobuf. (#2652)
This commit is contained in:
parent
84b154ebc0
commit
115623a6ee
|
@ -269,14 +269,20 @@ public final class FSImageFormatProtobuf {
|
||||||
String compressionCodec)
|
String compressionCodec)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
FileInputStream fin = new FileInputStream(filename);
|
FileInputStream fin = new FileInputStream(filename);
|
||||||
FileChannel channel = fin.getChannel();
|
try {
|
||||||
channel.position(section.getOffset());
|
|
||||||
InputStream in = new BufferedInputStream(new LimitInputStream(fin,
|
|
||||||
section.getLength()));
|
|
||||||
|
|
||||||
in = FSImageUtil.wrapInputStreamForCompression(conf,
|
FileChannel channel = fin.getChannel();
|
||||||
compressionCodec, in);
|
channel.position(section.getOffset());
|
||||||
return in;
|
InputStream in = new BufferedInputStream(new LimitInputStream(fin,
|
||||||
|
section.getLength()));
|
||||||
|
|
||||||
|
in = FSImageUtil.wrapInputStreamForCompression(conf,
|
||||||
|
compressionCodec, in);
|
||||||
|
return in;
|
||||||
|
} catch (IOException e) {
|
||||||
|
fin.close();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue