From 52504ea28080af9de93e757d2adf8a5603785ed8 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 25 Oct 2010 09:40:29 +0000 Subject: [PATCH] properly close streams. PR 50136 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1027003 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ .../apache/tools/ant/taskdefs/optional/unix/Symlink.java | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index cb7b78dbf..7ded7aa87 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -169,6 +169,10 @@ Fixed bugs: * ignored 's errorOnMissingDir attribute Bugzilla Report 50124. + * failed to close files when reading a list of symbolic + links from a properties file. + Bugzilla Report 50136. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java index 0ae517d41..9ea68d2ef 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java @@ -37,6 +37,7 @@ import java.io.FileOutputStream; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileNotFoundException; +import java.io.InputStream; import java.util.Vector; import java.util.HashSet; @@ -560,8 +561,10 @@ public class Symlink extends DispatchTask { File inc = new File(dir, incs[j]); File pf = inc.getParentFile(); Properties lnks = new Properties(); + InputStream is = null; try { - lnks.load(new BufferedInputStream(new FileInputStream(inc))); + is = new BufferedInputStream(new FileInputStream(inc)); + lnks.load(is); pf = pf.getCanonicalFile(); } catch (FileNotFoundException fnfe) { handleError("Unable to find " + incs[j] + "; skipping it."); @@ -570,6 +573,8 @@ public class Symlink extends DispatchTask { handleError("Unable to open " + incs[j] + " or its parent dir; skipping it."); continue; + } finally { + FileUtils.close(is); } lnks.list(new PrintStream( new LogOutputStream(this, Project.MSG_INFO)));