From 9ec1930ae7761d9f977d737ea678282f0d1b06e7 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 23 Oct 2001 14:10:29 +0000 Subject: [PATCH] add some extra savety measures. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269817 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/optional/PropertyFile.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index d79d7ff56..a0326ee00 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -203,20 +203,30 @@ public class PropertyFile extends Task if (m_propertyfile.exists()) { log("Updating property file: "+m_propertyfile.getAbsolutePath()); - FileInputStream fis = new FileInputStream(m_propertyfile); - BufferedInputStream bis = new BufferedInputStream(fis); - m_properties.load(bis); - if (fis != null) { - fis.close(); + FileInputStream fis = null; + try { + fis = new FileInputStream(m_propertyfile); + BufferedInputStream bis = new BufferedInputStream(fis); + m_properties.load(bis); + } finally { + if (fis != null) { + fis.close(); + } } } else { log("Creating new property file: "+ m_propertyfile.getAbsolutePath()); - FileOutputStream out = new FileOutputStream(m_propertyfile.getAbsolutePath()); - out.flush(); - out.close(); + FileOutputStream out = null; + try { + out = new FileOutputStream(m_propertyfile.getAbsolutePath()); + out.flush(); + } finally { + if (out != null) { + out.close(); + } + } } } catch(IOException ioe)