HDFS-16031. Possible Resource Leak in org.apache.hadoop.hdfs.server.aliasmap#InMemoryAliasMap (#3027)
This commit is contained in:
parent
e18d806212
commit
3fdeb7435a
@ -320,21 +320,15 @@ static File createSnapshot(InMemoryAliasMap aliasMap) throws IOException {
|
||||
private static File getCompressedAliasMap(File aliasMapDir)
|
||||
throws IOException {
|
||||
File outCompressedFile = new File(aliasMapDir.getParent(), TAR_NAME);
|
||||
BufferedOutputStream bOut = null;
|
||||
GzipCompressorOutputStream gzOut = null;
|
||||
TarArchiveOutputStream tOut = null;
|
||||
try {
|
||||
bOut = new BufferedOutputStream(
|
||||
Files.newOutputStream(outCompressedFile.toPath()));
|
||||
gzOut = new GzipCompressorOutputStream(bOut);
|
||||
tOut = new TarArchiveOutputStream(gzOut);
|
||||
|
||||
try (BufferedOutputStream bOut = new BufferedOutputStream(
|
||||
Files.newOutputStream(outCompressedFile.toPath()));
|
||||
GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(bOut);
|
||||
TarArchiveOutputStream tOut = new TarArchiveOutputStream(gzOut)){
|
||||
|
||||
addFileToTarGzRecursively(tOut, aliasMapDir, "", new Configuration());
|
||||
} finally {
|
||||
if (tOut != null) {
|
||||
tOut.finish();
|
||||
}
|
||||
IOUtils.cleanupWithLogger(null, tOut, gzOut, bOut);
|
||||
}
|
||||
|
||||
return outCompressedFile;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user