HDFS-12789. [READ] Image generation tool does not close an opened stream
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/87dc026b Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/87dc026b Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/87dc026b Branch: refs/heads/trunk Commit: 87dc026beec5d69a84771631ebca5fadb2f7195b Parents: c293cc8 Author: Virajith Jalaparti <viraj...@apache.org> Authored: Wed Nov 8 10:28:50 2017 -0800 Committer: Chris Douglas <cdoug...@apache.org> Committed: Fri Dec 15 17:51:39 2017 -0800 ---------------------------------------------------------------------- .../hadoop/hdfs/server/namenode/ImageWriter.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/87dc026b/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageWriter.java ---------------------------------------------------------------------- diff --git a/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageWriter.java b/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageWriter.java index ea1888a..390bb39 100644 --- a/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageWriter.java +++ b/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageWriter.java @@ -165,16 +165,23 @@ public class ImageWriter implements Closeable { // create directory and inode sections as side-files. // The details are written to files to avoid keeping them in memory. - dirsTmp = File.createTempFile("fsimg_dir", null); - dirsTmp.deleteOnExit(); - dirs = beginSection(new FileOutputStream(dirsTmp)); + FileOutputStream dirsTmpStream = null; + try { + dirsTmp = File.createTempFile("fsimg_dir", null); + dirsTmp.deleteOnExit(); + dirsTmpStream = new FileOutputStream(dirsTmp); + dirs = beginSection(dirsTmpStream); + } catch (IOException e) { + IOUtils.cleanupWithLogger(null, raw, dirsTmpStream); + throw e; + } + try { inodesTmp = File.createTempFile("fsimg_inode", null); inodesTmp.deleteOnExit(); inodes = new FileOutputStream(inodesTmp); } catch (IOException e) { - // appropriate to close raw? - IOUtils.cleanup(null, raw, dirs); + IOUtils.cleanupWithLogger(null, raw, dirsTmpStream, dirs); throw e; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org