From a16368d3f85e8ad068ebf65a2025c8cf90cf7d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=BChne?= Date: Tue, 21 Jan 2003 06:23:45 +0000 Subject: [PATCH] close the InputStream for property file loading explicitly instead of relying on the stream's finalize method --- .../tools/checkstyle/CheckStyleTask.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java index 0bcfdc84d..fccbd5280 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java @@ -276,8 +276,10 @@ public class CheckStyleTask // Load the properties file if specified if (mPropertiesFile != null) { + FileInputStream inStream = null; try { - retVal.load(new FileInputStream(mPropertiesFile)); + inStream = new FileInputStream(mPropertiesFile); + retVal.load(inStream); } catch (FileNotFoundException e) { throw new BuildException( @@ -289,6 +291,19 @@ public class CheckStyleTask "Error loading Properties file '" + mPropertiesFile + "'", e, getLocation()); } + finally { + try { + if (inStream != null) { + inStream.close(); + } + } + catch (IOException e) { + throw new BuildException( + "Error closing Properties file '" + + mPropertiesFile + "'", + e, getLocation()); + } + } } // Now override the properties specified