Author: adrianc
Date: Tue Jan  6 01:05:29 2015
New Revision: 1649701

URL: http://svn.apache.org/r1649701
Log:
Make sure InputStream is closed.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=1649701&r1=1649700&r2=1649701&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java 
(original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java Tue 
Jan  6 01:05:29 2015
@@ -1093,18 +1093,27 @@ public class UtilProperties implements S
             super(defaults);
         }
         public ExtendedProperties(URL url, Locale locale) throws IOException, 
InvalidPropertiesFormatException {
-            InputStream in = new BufferedInputStream(url.openStream());
-            if (url.getFile().endsWith(".xml")) {
-                xmlToProperties(in, locale, this);
-            } else {
-                load(in);
+            InputStream in = null;
+            try {
+                in = new BufferedInputStream(url.openStream());
+                if (url.getFile().endsWith(".xml")) {
+                    xmlToProperties(in, locale, this);
+                } else {
+                    load(in);
+                }
+            } finally {
+                if (in != null) {
+                    in.close();
+                }
             }
-            in.close();
         }
         @Override
         public void loadFromXML(InputStream in) throws IOException, 
InvalidPropertiesFormatException {
-            xmlToProperties(in, null, this);
-            in.close();
+            try {
+                xmlToProperties(in, null, this);
+            } finally {
+                in.close();
+            }
         }
     }
 }


Reply via email to