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

Reviewed-by: He Xiaoqiao <hexiaoqiao@apache.org>
(cherry picked from commit f5f3fc6fe9)
This commit is contained in:
Narges Shadab 2021-03-19 01:36:48 -07:00 committed by Wei-Chiu Chuang
parent 4abe6e6ac1
commit 3a355282c9
1 changed files with 6 additions and 1 deletions

View File

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