directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1410114 - /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java
Date Thu, 15 Nov 2012 23:52:46 GMT
Author: elecharny
Date: Thu Nov 15 23:52:46 2012
New Revision: 1410114

URL: http://svn.apache.org/viewvc?rev=1410114&view=rev
Log:
Fixed a connection leak if we can't bind the connection while trying to open a new one. See
DIRAPI-96.


Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java?rev=1410114&r1=1410113&r2=1410114&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/PoolableLdapConnectionFactory.java
Thu Nov 15 23:52:46 2012
@@ -81,7 +81,20 @@ public class PoolableLdapConnectionFacto
         LOG.debug( "Creating a LDAP connection" );
 
         LdapNetworkConnection connection = new LdapNetworkConnection( config );
-        connection.bind( config.getName(), config.getCredentials() );
+        
+        try
+        {
+            connection.bind( config.getName(), config.getCredentials() );
+        }
+        catch ( Exception e )
+        {
+            // We weren't able to bind : close the connection
+            connection.close();
+            
+            // And rethrow the exception
+            throw e;
+        }
+        
         return connection;
     }
 



Mime
View raw message