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