You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2014/11/04 08:01:05 UTC

svn commit: r1636512 - in /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api: LdapConnectionPool.java LdapNetworkConnection.java

Author: elecharny
Date: Tue Nov  4 07:01:04 2014
New Revision: 1636512

URL: http://svn.apache.org/r1636512
Log:
o Wait for the UnbindFuture to be completed
o Called the close() methods, which actually shutdown the connection, as requested by RFC 4511 : "
5.3. Termination of the LDAP session

   Termination of the LDAP session is typically initiated by the client sending an UnbindRequest ... each protocol peer gracefully terminates the LDAP session by ceasing exchanges at the LDAP message layer, tearing down any SASL layer, tearing down any TLS layer, and closing the transport connection."

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/api/LdapNetworkConnection.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=1636512&r1=1636511&r2=1636512&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 Tue Nov  4 07:01:04 2014
@@ -53,10 +53,10 @@ public class LdapConnectionPool extends 
     public LdapConnectionPool( LdapConnectionConfig connectionConfig,
         LdapApiService apiService, long timeout )
     {
-        this( connectionConfig, apiService, timeout, null );    
+        this( connectionConfig, apiService, timeout, null );
     }
-    
-    
+
+
     /**
      * Instantiates a new LDAP connection pool.
      *
@@ -82,6 +82,7 @@ public class LdapConnectionPool extends 
         this( factory, null );
     }
 
+
     /**
      * Instantiates a new LDAP connection pool.
      *
@@ -115,6 +116,7 @@ public class LdapConnectionPool extends 
     public LdapConnection getConnection() throws LdapException
     {
         LdapConnection connection;
+
         try
         {
             connection = super.borrowObject();
@@ -136,6 +138,7 @@ public class LdapConnectionPool extends 
             LOG.error( "An unexpected exception was thrown: ", e );
             throw new RuntimeException( e );
         }
+
         return connection;
     }
 

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1636512&r1=1636511&r2=1636512&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Tue Nov  4 07:01:04 2014
@@ -165,6 +165,7 @@ import org.apache.mina.transport.socket.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * This class is the base for every operations sent or received to and
  * from a LDAP server.
@@ -1666,7 +1667,7 @@ public class LdapNetworkConnection exten
 
         int newId = messageId.incrementAndGet();
         searchRequest.setMessageId( newId );
-        
+
         if ( searchRequest.isIgnoreReferrals() )
         {
             // We want to ignore the referral, inject the ManageDSAIT control in the request
@@ -1736,10 +1737,10 @@ public class LdapNetworkConnection exten
 
         // Send the request to the server
         // Use this for logging instead: WriteFuture unbindFuture = ldapSession.write( unbindRequest );
-        ldapSession.write( unbindRequest );
+        WriteFuture unbindFuture = ldapSession.write( unbindRequest );
 
         //LOG.debug( "waiting for unbindFuture" );
-        //unbindFuture.awaitUninterruptibly();
+        unbindFuture.awaitUninterruptibly( timeout );
         //LOG.debug( "unbindFuture done" );
 
         authenticated.set( false );
@@ -1748,6 +1749,19 @@ public class LdapNetworkConnection exten
         clearMaps();
 
         //  We now have to close the session
+        try
+        {
+            close();
+        }
+        catch ( IOException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        connected.set( false );
+
+        /*
         if ( ldapSession != null )
         {
             CloseFuture closeFuture = ldapSession.close( true );
@@ -1757,6 +1771,7 @@ public class LdapNetworkConnection exten
             LOG.debug( "closeFuture done" );
             connected.set( false );
         }
+        */
 
         // Last, not least, reset the MessageId value
         messageId.set( 0 );
@@ -3465,16 +3480,16 @@ public class LdapNetworkConnection exten
 
             Registries registries = schemaManager.getRegistries();
             List<Throwable> errors = new ArrayList<Throwable>();
-            
+
             for ( AttributeType atType : olsp.getAttributeTypes() )
             {
                 registries.buildReference( errors, atType );
-                registries.getAttributeTypeRegistry().register(atType);
+                registries.getAttributeTypeRegistry().register( atType );
             }
 
             for ( ObjectClass oc : olsp.getObjectClassTypes() )
             {
-                registries.buildReference(errors, oc);
+                registries.buildReference( errors, oc );
                 registries.getObjectClassRegistry().register( oc );
             }