directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lucasthei...@apache.org
Subject svn commit: r1613509 - in /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client: api/LdapConnectionPool.java template/LdapConnectionTemplate.java
Date Fri, 25 Jul 2014 20:06:16 GMT
Author: lucastheisen
Date: Fri Jul 25 20:06:16 2014
New Revision: 1613509

URL: http://svn.apache.org/r1613509
Log:
DIRAPI-199,DIRAPI-198: resolved bug in LdapConnectionTemplate that was closing connections
rather than returning them, removed invalid getUnboundConnection method from LdapConnectionPool

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java?rev=1613509&r1=1613508&r2=1613509&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionPool.java
Fri Jul 25 20:06:16 2014
@@ -118,6 +118,7 @@ public class LdapConnectionPool extends 
         try
         {
             connection = super.borrowObject();
+            LOG.trace( "borrowed connection {}", connection );
         }
         catch ( LdapException e )
         {
@@ -139,23 +140,6 @@ public class LdapConnectionPool extends 
     }
 
 
-    /**
-     * Returns an LdapConnection from the pool that is not bound to an
-     * identity.  This type of connection is useful when you want to bind
-     * yourself for authentication/authorization purposes.
-     *
-     * @return An unbound LdapConnection from the pool
-     * @throws Exception If an error occurs while obtaining a connection 
-     * from the factory
-     */
-    public LdapConnection getUnboundConnection() throws LdapException
-    {
-        LdapConnection connection = getConnection();
-        connection.unBind();
-        return connection;
-    }
-
-
     private static PoolableLdapConnectionFactory newPoolableConnectionFactory(
         LdapConnectionConfig connectionConfig, LdapApiService apiService,
         long timeout )
@@ -179,6 +163,7 @@ public class LdapConnectionPool extends 
         try
         {
             super.returnObject( connection );
+            LOG.trace( "returned connection {}", connection );
         }
         catch ( LdapException e )
         {

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java?rev=1613509&r1=1613508&r2=1613509&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/LdapConnectionTemplate.java
Fri Jul 25 20:06:16 2014
@@ -85,6 +85,7 @@ public class LdapConnectionTemplate impl
      */
     public LdapConnectionTemplate( LdapConnectionPool connectionPool )
     {
+        logger.debug( "creating new connection template from connectionPool" );
         this.connectionPool = connectionPool;
         this.passwordPolicyRequestControl = new PasswordPolicyDecorator(
             connectionPool.getLdapApiService() );
@@ -177,7 +178,7 @@ public class LdapConnectionTemplate impl
         LdapConnection connection = null;
         try
         {
-            connection = connectionPool.getUnboundConnection();
+            connection = connectionPool.getConnection();
             return authenticateConnection( connection, userDn, password );
         }
         catch ( LdapException e )
@@ -186,7 +187,7 @@ public class LdapConnectionTemplate impl
         }
         finally
         {
-            safeCloseLdapConnection( connection );
+            returnLdapConnection( connection );
         }
     }
 
@@ -367,13 +368,9 @@ public class LdapConnectionTemplate impl
         LdapConnection connection = null;
         try
         {
-            if ( asAdmin )
-            {
-                connection = connectionPool.getConnection();
-            }
-            else
+            connection = connectionPool.getConnection();
+            if ( !asAdmin )
             {
-                connection = connectionPool.getUnboundConnection();
                 authenticateConnection( connection, userDn, oldPassword );
             }
 
@@ -385,14 +382,7 @@ public class LdapConnectionTemplate impl
         }
         finally
         {
-            if ( asAdmin )
-            {
-                returnLdapConnection( connection );
-            }
-            else
-            {
-                safeCloseLdapConnection( connection );
-            }
+            returnLdapConnection( connection );
         }
     }
 
@@ -558,23 +548,6 @@ public class LdapConnectionTemplate impl
     }
 
 
-    private void safeCloseLdapConnection( LdapConnection connection )
-    {
-        if ( connection != null )
-        {
-            try
-            {
-                connection.close();
-            }
-            catch ( IOException e )
-            {
-                logger.error( "Unable to close ldap connection, might be leaking connections:",
e.getMessage() );
-                logger.debug( "Unable to close ldap connection, might be leaking connections:",
e );
-            }
-        }
-    }
-
-
     @Override
     public <T> T searchFirst( String baseDn, String filter, SearchScope scope,
         EntryMapper<T> entryMapper )



Mime
View raw message