Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 54966 invoked from network); 18 May 2010 20:47:43 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 May 2010 20:47:43 -0000 Received: (qmail 96300 invoked by uid 500); 18 May 2010 20:47:43 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 96242 invoked by uid 500); 18 May 2010 20:47:43 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 96234 invoked by uid 99); 18 May 2010 20:47:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 May 2010 20:47:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 May 2010 20:47:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BB53723889B6; Tue, 18 May 2010 20:47:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: felixk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100518204718.BB53723889B6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;