directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1484804 - in /directory/apacheds/trunk: ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ protocol-ldap/src/main/java/org/apache/...
Date Tue, 21 May 2013 13:31:20 GMT
Author: elecharny
Date: Tue May 21 13:31:20 2013
New Revision: 1484804

URL: http://svn.apache.org/r1484804
Log:
Fix for DIRAPI-140 : We don't close the cursor in the AbandondListener, we now do that when
the session has been canceled, in the writeRequests() method


Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1484804&r1=1484803&r2=1484804&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
Tue May 21 13:31:20 2013
@@ -22,7 +22,6 @@ package org.apache.directory.shared.clie
 
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -366,13 +365,8 @@ public void testSubDn() throws Exception
 @Test
 public void test_DIRAPI140() throws Exception
 {
-    for ( int i = 0; i < 1000; i++ )
+    for ( int i = 0; i < 10000; i++ )
     {
-        if ( i % 100 == 0 )
-        {
-            System.out.println( "Loop " + i );
-        }
-
         SearchRequest req = new SearchRequestImpl();
         req.setScope( SearchScope.SUBTREE );
         req.addAttributes( "*" );
@@ -384,7 +378,6 @@ public void test_DIRAPI140() throws Exce
 
         // We should have only one entry
         assertTrue( searchCursor.next() );
-        assertFalse( searchCursor.next() );
 
         searchCursor.close();
     }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java?rev=1484804&r1=1484803&r2=1484804&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java
Tue May 21 13:31:20 2013
@@ -20,7 +20,6 @@
 package org.apache.directory.server.ldap.handlers;
 
 
-import org.apache.directory.api.ldap.model.exception.OperationAbandonedException;
 import org.apache.directory.api.ldap.model.message.AbandonListener;
 import org.apache.directory.api.ldap.model.message.AbandonableRequest;
 import org.apache.directory.server.core.api.event.DirectoryListener;
@@ -76,24 +75,5 @@ public class SearchAbandonListener imple
         {
             ldapServer.getDirectoryService().getEventService().removeListener( listener );
         }
-
-        try
-        {
-            if ( ( cursor != null  ) && !cursor.isClosed() )
-            {
-                /*
-                 * When this method is called due to an abandon request it 
-                 * will close the cursor but other threads processing the 
-                 * search will get an OperationAbandonedException which as
-                 * seen below will make sure the proper handling is 
-                 * performed.
-                 */
-                cursor.close( new OperationAbandonedException() );
-            }
-        }
-        catch ( Exception e )
-        {
-            LOG.error( I18n.err( I18n.ERR_166, req.getMessageId() ), e );
-        }
     }
 }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java?rev=1484804&r1=1484803&r2=1484804&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
Tue May 21 13:31:20 2013
@@ -222,8 +222,8 @@ public class SearchRequestHandler extend
             }
         }
     }
-    
-    
+
+
     /**
      * Handle the replication request.
      */
@@ -405,6 +405,8 @@ public class SearchRequestHandler extend
 
             if ( req.isAbandoned() )
             {
+                cursor.close( new OperationAbandonedException() );
+
                 // The cursor has been closed by an abandon request.
                 if ( IS_DEBUG )
                 {
@@ -676,7 +678,7 @@ public class SearchRequestHandler extend
 
                 // If we had a cookie in the session, remove it
                 removeContext( session, pagedContext );
-                
+
                 return req.getResultResponse();
             }
             else
@@ -842,7 +844,7 @@ public class SearchRequestHandler extend
         }
         finally
         {
-            if ( ( cursor != null  ) && !cursor.isClosed() )
+            if ( ( cursor != null ) && !cursor.isClosed() )
             {
                 try
                 {
@@ -1212,7 +1214,7 @@ public class SearchRequestHandler extend
         try
         {
             isReferral = referralManager.isReferral( reqTargetDn );
-    
+
             if ( !isReferral )
             {
                 // Check if the entry has a parent which is a referral
@@ -1616,6 +1618,7 @@ public class SearchRequestHandler extend
     public void handleException( LdapSession session, ResultResponseRequest req, Exception
e )
     {
         LdapResult result = req.getResultResponse().getLdapResult();
+        Exception cause = null;
 
         /*
          * Set the result code or guess the best option.
@@ -1624,16 +1627,25 @@ public class SearchRequestHandler extend
 
         if ( e instanceof CursorClosedException )
         {
-            e = (Exception)((CursorClosedException)e).getCause();
+            cause = ( Exception ) ( ( CursorClosedException ) e ).getCause();
+
+            if ( cause == null )
+            {
+                cause = e;
+            }
+        }
+        else
+        {
+            cause = e;
         }
 
-        if ( e instanceof LdapOperationException )
+        if ( cause instanceof LdapOperationException )
         {
-            code = ( ( LdapOperationException ) e ).getResultCode();
+            code = ( ( LdapOperationException ) cause ).getResultCode();
         }
         else
         {
-            code = ResultCodeEnum.getBestEstimate( e, req.getType() );
+            code = ResultCodeEnum.getBestEstimate( cause, req.getType() );
         }
 
         result.setResultCode( code );
@@ -1643,23 +1655,19 @@ public class SearchRequestHandler extend
          * exception into the message if we are in debug mode.  Note we
          * embed the result code name into the message.
          */
-        String msg = code.toString() + ": failed for " + req + ": " + e.getLocalizedMessage();
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( msg, e );
-        }
+        String msg = code.toString() + ": failed for " + req + ": " + cause.getLocalizedMessage();
 
         if ( IS_DEBUG )
         {
-            msg += ":\n" + ExceptionUtils.getStackTrace( e );
+            LOG.debug( msg, cause );
+            msg += ":\n" + ExceptionUtils.getStackTrace( cause );
         }
 
         result.setDiagnosticMessage( msg );
 
-        if ( e instanceof LdapOperationException )
+        if ( cause instanceof LdapOperationException )
         {
-            LdapOperationException ne = ( LdapOperationException ) e;
+            LdapOperationException ne = ( LdapOperationException ) cause;
 
             // Add the matchedDN if necessary
             boolean setMatchedDn = code == ResultCodeEnum.NO_SUCH_OBJECT || code == ResultCodeEnum.ALIAS_PROBLEM



Mime
View raw message