changeset 172:b5e55f460f0b

Closed small file descriptor leak in loading SQL properties file. gnv-artifacts/trunk@209 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 12 Oct 2009 09:19:16 +0000
parents 7fb9441dd8af
children 1b2fc94766c9
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Fri Oct 09 07:54:48 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Oct 12 09:19:16 2009 +0000
@@ -1,3 +1,8 @@
+2009-10-12	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
+	Closed small file descriptor leak.
+
 2009-10-09  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/**/*.java Edited:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Fri Oct 09 07:54:48 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Mon Oct 12 09:19:16 2009 +0000
@@ -90,9 +90,18 @@
     private Properties getProperties(String filePath)
                                                      throws FileNotFoundException,
                                                      IOException {
-        InputStream inputStream = new FileInputStream(filePath);
-        Properties properties = new Properties();
-        properties.load(inputStream);
-        return properties;
+        InputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(filePath);
+            Properties properties = new Properties();
+            properties.load(inputStream);
+            return properties;
+        }
+        finally {
+            if (inputStream != null) {
+                try { inputStream.close(); }
+                catch (IOException ioe) {}
+            }
+        }
     }
 }

http://dive4elements.wald.intevation.org