directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r922680 - in /directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api: LdapConnection.java future/ResponseFuture.java
Date Sat, 13 Mar 2010 21:54:09 GMT
Author: kayyagari
Date: Sat Mar 13 21:54:08 2010
New Revision: 922680

URL: http://svn.apache.org/viewvc?rev=922680&view=rev
Log:
o fixed an issue with setting the cancel flag on future when user calls on LdapConnection.abandon()
o added a new method in LdapConnection to check if there exists a ResponseFuture for a given
request ID
o used the above created method in ResponseFuture.cancel() method to check whether to call
LdapConnection.abandon() or not

Modified:
    directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
    directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=922680&r1=922679&r2=922680&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
Sat Mar 13 21:54:08 2010
@@ -942,9 +942,8 @@ public class LdapConnection extends IoHa
         // this is a sync operation send cancel signal to the corresponding ResponseFuture
         if ( rf != null )
         {
-            // no need to call cancel on future cause the future inturn calls LdapConnection.abandon(
messageId )
-            //LOG.debug( "sending cancel signal to future" );
-            //rf.cancel( true );
+            LOG.debug( "sending cancel signal to future" );
+            rf.cancel( true );
         }
         else
         {
@@ -3348,4 +3347,16 @@ public class LdapConnection extends IoHa
     {
         futureMap.clear();
     }
+    
+    
+    /**
+     * checks if there is a ResponseFuture associated with the given message id 
+     * 
+     * @param messageId ID of the request
+     * @return true if there is a non-null future exists, false otherwise
+     */
+    public boolean doesFutureExistFor( Integer messageId )
+    {
+        return futureMap.get( messageId ) != null;
+    }
 }

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java?rev=922680&r1=922679&r2=922680&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
Sat Mar 13 21:54:08 2010
@@ -75,11 +75,18 @@ public class ResponseFuture<R> implement
             return cancelled;
         }
         
-        // Send an abandonRequest
-        connection.abandon( messageId );
+        // set the cancel flag first
+        cancelled = true;
+
+        // Send an abandonRequest only if this future exists
+        if( connection.doesFutureExistFor( messageId ) )
+        {
+            connection.abandon( messageId );
+        }
         
+        // then clear the queue, cause the might be some incoming messages before this abandon
request
+        // hits the server
         queue.clear();
-        cancelled = true;
         
         return cancelled;
     }



Mime
View raw message