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 2010/05/17 01:53:42 UTC

svn commit: r944942 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java

Author: elecharny
Date: Sun May 16 23:53:42 2010
New Revision: 944942

URL: http://svn.apache.org/viewvc?rev=944942&view=rev
Log:
o Stores the PagedSearch context in a ConcurrentHashMap
o Removed the useless synchronizations

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=944942&r1=944941&r2=944942&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java Sun May 16 23:53:42 2010
@@ -102,7 +102,7 @@ public class LdapSession
         outstandingRequests = new ConcurrentHashMap<Integer, InternalAbandonableRequest>();
         bindStatus = BindStatus.ANONYMOUS;
         saslProperties = new HashMap<String, Object>();
-        pagedSearchContexts = new HashMap<Integer, PagedSearchContext>();
+        pagedSearchContexts = new ConcurrentHashMap<Integer, PagedSearchContext>();
     }
     
     
@@ -426,24 +426,22 @@ public class LdapSession
      */
     public void addPagedSearchContext( PagedSearchContext context ) throws Exception
     {
-        synchronized ( pagedSearchContexts )
+        PagedSearchContext oldContext = pagedSearchContexts.put( context.getCookieValue(), context );
+        
+        if ( oldContext != null )
         {
-            PagedSearchContext oldContext = pagedSearchContexts.put( context.getCookieValue(), context );
+            // ??? Very unlikely to happen ...
+            EntryFilteringCursor cursor = oldContext.getCursor();
             
-            if ( oldContext != null )
+            if ( cursor != null )
             {
-                EntryFilteringCursor cursor = oldContext.getCursor();
-                
-                if ( cursor != null )
+                try
+                {
+                    cursor.close();
+                }
+                catch ( Exception e )
                 {
-                    try
-                    {
-                        cursor.close();
-                    }
-                    catch ( Exception e )
-                    {
-                        LOG.error( I18n.err( I18n.ERR_172, e.getLocalizedMessage() ) );
-                    }
+                    LOG.error( I18n.err( I18n.ERR_172, e.getLocalizedMessage() ) );
                 }
             }
         }
@@ -456,12 +454,9 @@ public class LdapSession
      * @param contextId The context ID to remove
      * @return The removed context if any found
      */
-    public PagedSearchContext removePagedSearchContext( long contextId )
+    public PagedSearchContext removePagedSearchContext( int contextId )
     {
-        synchronized ( pagedSearchContexts )
-        {
-            return pagedSearchContexts.remove( contextId );
-        }
+        return pagedSearchContexts.remove( contextId );
     }
     
     
@@ -472,12 +467,12 @@ public class LdapSession
      */
     public PagedSearchContext getPagedSearchContext( int contextId )
     {
-        synchronized ( pagedSearchContexts )
-        {
-            return pagedSearchContexts.get( contextId );
-        }
+        PagedSearchContext ctx =  pagedSearchContexts.get( contextId );
+        
+        return ctx;
     }
     
+    
     /**
      * The principal and remote address associated with this session.
      * @see Object#toString()