HDFS-15791. Possible Resource Leak in FSImageFormatProtobuf. (#2652)

This commit is contained in:
Narges Shadab 2021-02-01 01:56:59 -08:00 committed by GitHub
parent 84b154ebc0
commit 115623a6ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -269,14 +269,20 @@ public InputStream getInputStreamForSection(FileSummary.Section section,
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;
}
}
/**