From b3b1c6dcc6128fab6b369205c12bb5d672307f7f Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 21 Sep 2004 11:37:05 +0000 Subject: [PATCH] Close property file. PR: 30469 Submitted by: Juerg Wanner git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276873 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Replace.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index 5c3c864dc..480b2d01e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -328,8 +328,10 @@ public class Replace extends MatchingTask { public Properties getProperties(File propertyFile) throws BuildException { Properties properties = new Properties(); + FileInputStream in = null; try { - properties.load(new FileInputStream(propertyFile)); + in = new FileInputStream(propertyFile); + properties.load(in); } catch (FileNotFoundException e) { String message = "Property file (" + propertyFile.getPath() + ") not found."; @@ -338,6 +340,14 @@ public class Replace extends MatchingTask { String message = "Property file (" + propertyFile.getPath() + ") cannot be loaded."; throw new BuildException(message); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + // ignore + } + } } return properties;