directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r945874 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
Date Tue, 18 May 2010 20:47:18 GMT
Author: felixk
Date: Tue May 18 20:47:18 2010
New Revision: 945874

URL: http://svn.apache.org/viewvc?rev=945874&view=rev
Log:
Avoid file descriptor leaks. Do an active close of the IO stream.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?rev=945874&r1=945873&r2=945874&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
Tue May 18 20:47:18 2010
@@ -21,9 +21,9 @@ package org.apache.directory.shared.ldap
 
 
 import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
 import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Properties;
@@ -115,6 +115,8 @@ public class PropertiesUtils
      *            a class to use for relative path references
      * @return the static properties
      */
+    // This will suppress PMD.EmptyCatchBlock warnings in this method
+    @SuppressWarnings("PMD.EmptyCatchBlock")
     public static Properties getStaticProperties( Class<?> ref )
     {
         final Properties properties = new Properties();
@@ -132,6 +134,20 @@ public class PropertiesUtils
             {
                 return properties;
             }
+            finally
+            {
+                if ( input != null )
+                {
+                    try
+                    {
+                        input.close();
+                    }
+                    catch ( IOException e )
+                    {
+                        // Empty catch, we can't more than trying to close
+                    }
+                }
+            }
         }
 
         return properties;
@@ -147,6 +163,8 @@ public class PropertiesUtils
      *            the relative path to the resoruce
      * @return the static properties
      */
+    // This will suppress PMD.EmptyCatchBlock warnings in this method
+    @SuppressWarnings("PMD.EmptyCatchBlock")
     public static Properties getStaticProperties( Class<?> ref, String path )
     {
         Properties properties = new Properties();
@@ -165,6 +183,20 @@ public class PropertiesUtils
         {
             return properties;
         }
+        finally
+        {
+            if ( input != null )
+            {
+                try
+                {
+                    input.close();
+                }
+                catch ( IOException e )
+                {
+                    // Empty catch, we can't more than trying to close
+                }
+            }
+        }
 
         return properties;
     }
@@ -221,6 +253,8 @@ public class PropertiesUtils
      *            the path to the resource
      * @return the loaded or new Properties
      */
+    // This will suppress PMD.EmptyCatchBlock warnings in this method
+    @SuppressWarnings("PMD.EmptyCatchBlock")
     public static Properties getProperties( ClassLoader classloader, String path )
     {
         Properties properties = new Properties();
@@ -236,6 +270,20 @@ public class PropertiesUtils
             {
                 return properties;
             }
+            finally
+            {
+                if ( input != null )
+                {
+                    try
+                    {
+                        input.close();
+                    }
+                    catch ( IOException e )
+                    {
+                        // Empty catch, we can't more than trying to close
+                    }
+                }
+            }
         }
 
         return properties;
@@ -252,6 +300,8 @@ public class PropertiesUtils
      *            the relative path to the resource
      * @return the loaded or new Properties
      */
+    // This will suppress PMD.EmptyCatchBlock warnings in this method
+    @SuppressWarnings("PMD.EmptyCatchBlock")
     public static Properties getProperties( Class<?> clazz, String path )
     {
         Properties properties = new Properties();
@@ -267,6 +317,20 @@ public class PropertiesUtils
             {
                 return properties;
             }
+            finally
+            {
+                if ( input != null )
+                {
+                    try
+                    {
+                        input.close();
+                    }
+                    catch ( IOException e )
+                    {
+                        // Empty catch, we can't more than trying to close
+                    }
+                }
+            }
         }
 
         return properties;



Mime
View raw message