HDFS-15868. Possible Resource Leak in EditLogFileOutputStream (#2736). Contributed by Narges Shadab.

Reviewed-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
Narges Shadab 2021-03-19 01:36:48 -07:00 committed by GitHub
parent 3d4ea4b336
commit f5f3fc6fe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -88,7 +88,12 @@ public class EditLogFileOutputStream extends EditLogOutputStream {
} else {
rp = new RandomAccessFile(name, "rws");
}
fp = new FileOutputStream(rp.getFD()); // open for append
try {
fp = new FileOutputStream(rp.getFD()); // open for append
} catch (IOException e) {
IOUtils.closeStream(rp);
throw e;
}
fc = rp.getChannel();
fc.position(fc.size());
}