directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1422718 - in /directory/apacheds/trunk: core-shared/src/main/java/org/apache/directory/server/core/shared/ core/src/main/java/org/apache/directory/server/core/ interceptors/admin/src/main/java/org/apache/directory/server/core/admin/ interc...
Date Sun, 16 Dec 2012 23:49:43 GMT
Author: elecharny
Date: Sun Dec 16 23:49:41 2012
New Revision: 1422718

URL: http://svn.apache.org/viewvc?rev=1422718&view=rev
Log:
Moved the lock() calls out of a try{} and moved the unlock inside the finally{} clause. This is a fix for DIRSERVER-1782

Modified:
    directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
    directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
    directory/apacheds/trunk/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
    directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Modified: directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java (original)
+++ directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java Sun Dec 16 23:49:41 2012
@@ -75,16 +75,21 @@ public class ReferralManagerImpl impleme
     {
         lockWrite();
 
-        referrals = new DnNode<Entry>();
-        PartitionNexus nexus = directoryService.getPartitionNexus();
-
-        Set<String> suffixes = nexus.listSuffixes();
-        OBJECT_CLASS_AT = directoryService.getSchemaManager().getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
-
-        init( directoryService, suffixes.toArray( new String[]
-            {} ) );
-
-        unlock();
+        try
+        {
+            referrals = new DnNode<Entry>();
+            PartitionNexus nexus = directoryService.getPartitionNexus();
+    
+            Set<String> suffixes = nexus.listSuffixes();
+            OBJECT_CLASS_AT = directoryService.getSchemaManager().getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
+    
+            init( directoryService, suffixes.toArray( new String[]
+                {} ) );
+        }
+        finally
+        {
+            unlock();
+        }
     }
 
 
@@ -184,11 +189,16 @@ public class ReferralManagerImpl impleme
                     // Lock the referralManager
                     lockWrite();
 
-                    // Add it at the right place
-                    addReferral( entry );
-
-                    // Unlock the referralManager
-                    unlock();
+                    try
+                    {
+                        // Add it at the right place
+                        addReferral( entry );
+                    }
+                    finally
+                    { 
+                        // Unlock the referralManager
+                        unlock();
+                    }
                 }
 
                 cursor.close();

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Sun Dec 16 23:49:41 2012
@@ -472,10 +472,10 @@ public class DefaultDirectoryService imp
     {
         List<Interceptor> cloned = new ArrayList<Interceptor>();
 
+        readLock.lock();
+
         try
         {
-            readLock.lock();
-
             cloned.addAll( interceptors );
 
             return cloned;
@@ -496,9 +496,10 @@ public class DefaultDirectoryService imp
     {
         List<String> cloned = new ArrayList<String>();
 
+        readLock.lock();
+
         try
         {
-            readLock.lock();
             cloned.addAll( operationInterceptors.get( operation ) );
 
             return cloned;
@@ -516,9 +517,10 @@ public class DefaultDirectoryService imp
      */
     private void initOperationsList()
     {
+        writeLock.lock();
+
         try
         {
-            writeLock.lock();
             operationInterceptors = new ConcurrentHashMap<OperationEnum, List<String>>();
 
             for ( OperationEnum operation : OperationEnum.getOperations() )
@@ -600,10 +602,10 @@ public class DefaultDirectoryService imp
         // First, init the interceptor
         interceptor.init( this );
 
+        writeLock.lock();
+
         try
         {
-            writeLock.lock();
-
             for ( OperationEnum operation : OperationEnum.getOperations() )
             {
                 List<String> operationList = operationInterceptors.get( operation );
@@ -653,10 +655,10 @@ public class DefaultDirectoryService imp
     {
         Interceptor interceptor = interceptorNames.get( interceptorName );
 
+        writeLock.lock();
+
         try
         {
-            writeLock.lock();
-
             for ( OperationEnum operation : OperationEnum.getOperations() )
             {
                 List<String> operationList = operationInterceptors.get( operation );
@@ -2048,9 +2050,10 @@ public class DefaultDirectoryService imp
      */
     public Interceptor getInterceptor( String interceptorName )
     {
+        readLock.lock();
+
         try
         {
-            readLock.lock();
             return interceptorNames.get( interceptorName );
         }
         finally
@@ -2085,10 +2088,11 @@ public class DefaultDirectoryService imp
      */
     public void addAfter( String interceptorName, Interceptor interceptor )
     {
+        writeLock.lock();
+
         try
         {
             int position = 0;
-            writeLock.lock();
 
             // Find the position
             for ( Interceptor inter : interceptors )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java Sun Dec 16 23:49:41 2012
@@ -336,47 +336,45 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+        try
         {
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            // Depending on the Context.REFERRAL property value, we will throw
-            // a different exception.
-            if ( addContext.isReferralIgnored() )
+            if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                directoryService.getReferralManager().unlock();
-
-                LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                throw exception;
-            }
-            else
-            {
-                // Unlock the referral manager
-                directoryService.getReferralManager().unlock();
-
-                LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                throw exception;
+                Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( addContext.isReferralIgnored() )
+                {
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
+                }
+                else
+                {
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
             }
         }
-        else
+        finally
         {
-            // Unlock the ReferralManager
+            // Unlock the referral manager
             directoryService.getReferralManager().unlock();
+        }
+            
+        // Call the Add method
+        Interceptor head = directoryService.getInterceptor( addContext.getNextInterceptor() );
 
-            // Call the Add method
-            Interceptor head = directoryService.getInterceptor( addContext.getNextInterceptor() );
-
-            try
-            {
-                lockWrite();
+        lockWrite();
 
-                head.add( addContext );
-            }
-            finally
-            {
-                unlockWrite();
-            }
+        try
+        {
+            head.add( addContext );
+        }
+        finally
+        {
+            unlockWrite();
         }
 
         if ( IS_DEBUG )
@@ -402,10 +400,10 @@ public class DefaultOperationManager imp
         // Call the Delete method
         Interceptor head = directoryService.getInterceptor( bindContext.getNextInterceptor() );
 
+        lockRead();
+
         try
         {
-            lockRead();
-
             head.bind( bindContext );
         }
         finally
@@ -438,52 +436,49 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
-            {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !compareContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
-            }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( compareContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !compareContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( compareContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
                 }
             }
         }
-
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        finally
+        {
+            // Unlock the ReferralManager
+            directoryService.getReferralManager().unlock();
+        }
 
         // populate the context with the old entry
         compareContext.setOriginalEntry( getOriginalEntry( compareContext ) );
@@ -493,10 +488,10 @@ public class DefaultOperationManager imp
 
         boolean result = false;
 
+        lockRead();
+
         try
         {
-            lockRead();
-
             result = head.compare( compareContext );
         }
         finally
@@ -533,59 +528,56 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
-            {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !deleteContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
-            }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // We can't delete an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( deleteContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !deleteContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // We can't delete an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( deleteContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
                 }
             }
         }
-
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        finally
+        {
+            // Unlock the ReferralManager
+            directoryService.getReferralManager().unlock();
+        }
 
         // populate the context with the old entry
+        lockWrite();
+
         try
         {
-            lockWrite();
-
             eagerlyPopulateFields( deleteContext );
 
             // Call the Delete method
@@ -647,10 +639,10 @@ public class DefaultOperationManager imp
 
         boolean result = false;
 
+        lockRead();
+
         try
         {
-            lockRead();
-
             result = head.hasEntry( hasEntryContext );
         }
         finally
@@ -683,10 +675,10 @@ public class DefaultOperationManager imp
 
         Entry entry = null;
 
+        lockRead();
+
         try
         {
-            lockRead();
-
             entry = head.lookup( lookupContext );
         }
         finally
@@ -725,65 +717,62 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         referralManager.lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = referralManager.getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            if ( referralManager.isReferral( dn ) )
-            {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !modifyContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    referralManager.unlock();
-
-                    // We have found a parent referral for the current Dn
-                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
-            }
-            else if ( referralManager.hasParentReferral( dn ) )
-            {
-                // We can't delete an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( modifyContext.isReferralIgnored() )
-                {
-                    referralManager.unlock();
-
-                    // We have found a parent referral for the current Dn
-                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    referralManager.unlock();
-
-                    // We have found a parent referral for the current Dn
-                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = referralManager.getParentReferral( dn );
+    
+            if ( parentEntry != null )
+            {
+                if ( referralManager.isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !modifyContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        // We have found a parent referral for the current Dn
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( referralManager.hasParentReferral( dn ) )
+                {
+                    // We can't delete an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( modifyContext.isReferralIgnored() )
+                    {
+                        // We have found a parent referral for the current Dn
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        // We have found a parent referral for the current Dn
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
                 }
             }
         }
+        finally
+        {
+            // Unlock the ReferralManager
+            referralManager.unlock();
+        }
 
-        // Unlock the ReferralManager
-        referralManager.unlock();
+        lockWrite();
 
         try
         {
-            lockWrite();
-
             // populate the context with the old entry
             eagerlyPopulateFields( modifyContext );
 
@@ -829,74 +818,69 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !moveContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
-            }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !moveContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // We can't delete an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( moveContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+            }
+            
+            // Now, check the destination
+            // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
+            // as stated by RFC 3296 Section 5.6.2
+            if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
+                || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
             {
-                // We can't delete an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( moveContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
+                LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
+                //exception.setRemainingName( dn );
 
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
+                throw exception;
             }
-        }
 
-        // Now, check the destination
-        // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
-        // as stated by RFC 3296 Section 5.6.2
-        if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
-            || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
+        }
+        finally
         {
             // Unlock the referral manager
             directoryService.getReferralManager().unlock();
-
-            LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
-            //exception.setRemainingName( dn );
-
-            throw exception;
         }
 
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        lockWrite();
 
         try
         {
-            lockWrite();
-
             Entry originalEntry = getOriginalEntry( moveContext );
 
             moveContext.setOriginalEntry( originalEntry );
@@ -939,80 +923,74 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !moveAndRenameContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !moveAndRenameContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // We can't delete an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( moveAndRenameContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
                 }
             }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
-            {
-                // We can't delete an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( moveAndRenameContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
 
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
+            // Now, check the destination
+            // Normalize the moveAndRenameContext Dn
+            Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
+            newSuperiorDn.apply( directoryService.getSchemaManager() );
+    
+            // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
+            // as stated by RFC 3296 Section 5.6.2
+            if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
+                || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
+            {
+                // The parent Dn is a referral, we have to issue a AffectMultipleDsas result
+                // as stated by RFC 3296 Section 5.6.2
+                LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
+                //exception.setRemainingName( dn );
+    
+                throw exception;
             }
         }
-
-        // Now, check the destination
-        // Normalize the moveAndRenameContext Dn
-        Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
-        newSuperiorDn.apply( directoryService.getSchemaManager() );
-
-        // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
-        // as stated by RFC 3296 Section 5.6.2
-        if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
-            || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
+        finally
         {
-            // Unlock the referral manager
+            // Unlock the ReferralManager
             directoryService.getReferralManager().unlock();
-
-            // The parent Dn is a referral, we have to issue a AffectMultipleDsas result
-            // as stated by RFC 3296 Section 5.6.2
-            LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
-            //exception.setRemainingName( dn );
-
-            throw exception;
         }
 
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        lockWrite();
 
         try
         {
-            lockWrite();
-
             moveAndRenameContext.setOriginalEntry( getOriginalEntry( moveAndRenameContext ) );
             moveAndRenameContext.setModifiedEntry( moveAndRenameContext.getOriginalEntry().clone() );
 
@@ -1063,62 +1041,59 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
-            {
-                // This is a referral. We can delete it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !renameContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
-            }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // We can't delete an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( renameContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can delete it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !renameContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // We can't delete an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( renameContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                        throw exception;
+                    }
                 }
             }
         }
-
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        finally
+        {
+            // Unlock the ReferralManager
+            directoryService.getReferralManager().unlock();
+        }
 
         // Call the rename method
         // populate the context with the old entry
 
+        lockWrite();
+
         try
         {
-            lockWrite();
-
             eagerlyPopulateFields( renameContext );
             Entry originalEntry = getOriginalEntry( renameContext );
             renameContext.setOriginalEntry( originalEntry );
@@ -1162,66 +1137,63 @@ public class DefaultOperationManager imp
         // We have to deal with the referral first
         directoryService.getReferralManager().lockRead();
 
-        // Check if we have an ancestor for this Dn
-        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-        if ( parentEntry != null )
+        try
         {
-            // We have found a parent referral for the current Dn
-            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-            if ( directoryService.getReferralManager().isReferral( dn ) )
-            {
-                // This is a referral. We can return it if the ManageDsaIt flag is true
-                // Otherwise, we just throw a LdapReferralException
-                if ( !searchContext.isReferralIgnored() )
-                {
-                    // Throw a Referral Exception
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
-                        searchContext.getScope() );
-                    throw exception;
-                }
-            }
-            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+            // Check if we have an ancestor for this Dn
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+    
+            if ( parentEntry != null )
             {
-                // We can't search an entry which has an ancestor referral
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( searchContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
-                        searchContext.getScope() );
-                    throw exception;
+                // We have found a parent referral for the current Dn
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+    
+                if ( directoryService.getReferralManager().isReferral( dn ) )
+                {
+                    // This is a referral. We can return it if the ManageDsaIt flag is true
+                    // Otherwise, we just throw a LdapReferralException
+                    if ( !searchContext.isReferralIgnored() )
+                    {
+                        // Throw a Referral Exception
+                        LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
+                            searchContext.getScope() );
+                        throw exception;
+                    }
+                }
+                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                {
+                    // We can't search an entry which has an ancestor referral
+    
+                    // Depending on the Context.REFERRAL property value, we will throw
+                    // a different exception.
+                    if ( searchContext.isReferralIgnored() )
+                    {
+                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                        throw exception;
+                    }
+                    else
+                    {
+                        LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
+                            searchContext.getScope() );
+                        throw exception;
+                    }
                 }
             }
         }
-
-        // Unlock the ReferralManager
-        directoryService.getReferralManager().unlock();
+        finally
+        {
+            // Unlock the ReferralManager
+            directoryService.getReferralManager().unlock();
+        }
 
         // Call the Search method
         Interceptor head = directoryService.getInterceptor( searchContext.getNextInterceptor() );
 
         EntryFilteringCursor cursor = null;
 
+        lockRead();
+
         try
         {
-            lockRead();
-
             cursor = head.search( searchContext );
         }
         finally

Modified: directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java Sun Dec 16 23:49:41 2012
@@ -1153,8 +1153,15 @@ public class AdministrativePointIntercep
         List<Entry> administrativePoints = getAdministrativePoints();
 
         lockWrite();
-        addAdminPointCache( administrativePoints );
-        unlock();
+        
+        try
+        {
+            addAdminPointCache( administrativePoints );
+        }
+        finally
+        {
+            unlock();
+        }
     }
 
 
@@ -1212,22 +1219,27 @@ public class AdministrativePointIntercep
         // Protect the AP caches against concurrent access
         lockWrite();
 
-        // Loop on all the added roles to check if they are valid
-        for ( Value<?> role : adminPoint )
+        try
         {
-            checkAddRole( role, adminPoint, dn );
+            // Loop on all the added roles to check if they are valid
+            for ( Value<?> role : adminPoint )
+            {
+                checkAddRole( role, adminPoint, dn );
+            }
+    
+            // Ok, we are golden.
+            next( addContext );
+    
+            String apUuid = entry.get( ENTRY_UUID_AT ).getString();
+    
+            // Now, update the AdminPoint cache
+            createAdministrativePoints( adminPoint, dn, apUuid );
+        }
+        finally
+        {
+            // Release the APCaches lock
+            unlock();
         }
-
-        // Ok, we are golden.
-        next( addContext );
-
-        String apUuid = entry.get( ENTRY_UUID_AT ).getString();
-
-        // Now, update the AdminPoint cache
-        createAdministrativePoints( adminPoint, dn, apUuid );
-
-        // Release the APCaches lock
-        unlock();
 
         LOG.debug( "Added an Administrative Point at {}", dn );
 
@@ -1267,26 +1279,31 @@ public class AdministrativePointIntercep
         // Protect the AP caches against concurrent access
         lockWrite();
 
-        // Check that the removed AdministrativeRoles are valid. We don't have to do
-        // any other check, as the deleted entry has no children.
-        for ( Value<?> role : adminPoint )
+        try
         {
-            if ( !isValidRole( role.getString() ) )
+            // Check that the removed AdministrativeRoles are valid. We don't have to do
+            // any other check, as the deleted entry has no children.
+            for ( Value<?> role : adminPoint )
             {
-                String message = "Cannot remove the given role, it's not a valid one :" + role;
-                LOG.error( message );
-                throw new LdapUnwillingToPerformException( message );
+                if ( !isValidRole( role.getString() ) )
+                {
+                    String message = "Cannot remove the given role, it's not a valid one :" + role;
+                    LOG.error( message );
+                    throw new LdapUnwillingToPerformException( message );
+                }
             }
+    
+            // Ok, we can remove the AP
+            next( deleteContext );
+    
+            // Now, update the AdminPoint cache
+            deleteAdminPointCache( adminPoint, deleteContext );
+        }
+        finally
+        {
+            // Release the APCaches lock
+            unlock();
         }
-
-        // Ok, we can remove the AP
-        next( deleteContext );
-
-        // Now, update the AdminPoint cache
-        deleteAdminPointCache( adminPoint, deleteContext );
-
-        // Release the APCaches lock
-        unlock();
 
         LOG.debug( "Deleted an Administrative Point at {}", dn );
 

Modified: directory/apacheds/trunk/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Sun Dec 16 23:49:41 2012
@@ -254,9 +254,14 @@ public class ReferralInterceptor extends
             // We have to add it to the referralManager
             referralManager.lockWrite();
 
-            referralManager.addReferral( entry );
-
-            referralManager.unlock();
+            try
+            {
+                referralManager.addReferral( entry );
+            }
+            finally
+            {
+                referralManager.unlock();
+            }
         }
     }
 
@@ -291,9 +296,14 @@ public class ReferralInterceptor extends
             // We have to remove it from the referralManager
             referralManager.lockWrite();
 
-            referralManager.removeReferral( entry );
-
-            referralManager.unlock();
+            try
+            {
+                referralManager.removeReferral( entry );
+            }
+            finally
+            {
+                referralManager.unlock();
+            }
         }
     }
 
@@ -333,13 +343,18 @@ public class ReferralInterceptor extends
         {
             referralManager.lockWrite();
 
-            if ( referralManager.isReferral( newEntry.getDn() ) )
+            try
             {
-                referralManager.removeReferral( modifyContext.getEntry() );
-                referralManager.addReferral( newEntry );
+                if ( referralManager.isReferral( newEntry.getDn() ) )
+                {
+                    referralManager.removeReferral( modifyContext.getEntry() );
+                    referralManager.addReferral( newEntry );
+                }
+            }
+            finally
+            {
+                referralManager.unlock();
             }
-
-            referralManager.unlock();
         }
     }
 
@@ -349,8 +364,6 @@ public class ReferralInterceptor extends
      **/
     public void move( MoveOperationContext moveContext ) throws LdapException
     {
-        Dn newDn = moveContext.getNewDn();
-
         // Check if the entry is a referral itself
         boolean isReferral = isReferral( moveContext.getOriginalEntry() );
 
@@ -361,10 +374,15 @@ public class ReferralInterceptor extends
             // Update the referralManager
             referralManager.lockWrite();
 
-            referralManager.addReferral( moveContext.getModifiedEntry() );
-            referralManager.removeReferral( moveContext.getOriginalEntry() );
-
-            referralManager.unlock();
+            try
+            {
+                referralManager.addReferral( moveContext.getModifiedEntry() );
+                referralManager.removeReferral( moveContext.getOriginalEntry() );
+            }
+            finally
+            {
+                referralManager.unlock();
+            }
         }
     }
 
@@ -386,10 +404,15 @@ public class ReferralInterceptor extends
 
             referralManager.lockWrite();
 
-            referralManager.addReferral( newEntry );
-            referralManager.removeReferral( moveAndRenameContext.getOriginalEntry() );
-
-            referralManager.unlock();
+            try
+            {
+                referralManager.addReferral( newEntry );
+                referralManager.removeReferral( moveAndRenameContext.getOriginalEntry() );
+            }
+            finally
+            {
+                referralManager.unlock();
+            }
         }
     }
 
@@ -414,10 +437,15 @@ public class ReferralInterceptor extends
 
             referralManager.lockWrite();
 
-            referralManager.addReferral( newEntry );
-            referralManager.removeReferral( ( ( ClonedServerEntry ) renameContext.getEntry() ).getOriginalEntry() );
-
-            referralManager.unlock();
+            try
+            {
+                referralManager.addReferral( newEntry );
+                referralManager.removeReferral( ( ( ClonedServerEntry ) renameContext.getEntry() ).getOriginalEntry() );
+            }
+            finally
+            {
+                referralManager.unlock();
+            }
         }
     }
 }

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=1422718&r1=1422717&r2=1422718&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 Sun Dec 16 23:49:41 2012
@@ -1208,16 +1208,22 @@ public class SearchRequestHandler extend
         // Check if the entry itself is a referral
         referralManager.lockRead();
 
-        isReferral = referralManager.isReferral( reqTargetDn );
-
-        if ( !isReferral )
+        try
+        {
+            isReferral = referralManager.isReferral( reqTargetDn );
+    
+            if ( !isReferral )
+            {
+                // Check if the entry has a parent which is a referral
+                isparentReferral = referralManager.hasParentReferral( reqTargetDn );
+            }
+        }
+        finally
         {
-            // Check if the entry has a parent which is a referral
-            isparentReferral = referralManager.hasParentReferral( reqTargetDn );
+            // Unlock the ReferralManager
+            referralManager.unlock();
         }
 
-        referralManager.unlock();
-
         if ( !isReferral && !isparentReferral )
         {
             // This is not a referral and it does not have a parent which

Modified: directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java (original)
+++ directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java Sun Dec 16 23:49:41 2012
@@ -59,7 +59,7 @@ public class CreateKdcServerAnnotationTe
         assertEquals( "CreateKdcServerAnnotationTest-class", directoryService.getInstanceId() );
 
         KdcServer server = ServerAnnotationProcessor.getKdcServer( directoryService,
-            AvailablePortFinder.getNextAvailable( 1024 ) );
+            AvailablePortFinder.getNextAvailable() );
 
         assertEquals( 2, server.getTransports().length );
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1422718&r1=1422717&r2=1422718&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Sun Dec 16 23:49:41 2012
@@ -589,10 +589,10 @@ public abstract class AbstractBTreeParti
             Dn entryDn = entry.getDn();
 
             // check if the entry already exists
+            lockRead();
+
             try
             {
-                lockRead();
-
                 if ( getEntryId( entryDn ) != null )
                 {
                     LdapEntryAlreadyExistsException ne = new LdapEntryAlreadyExistsException(
@@ -624,10 +624,10 @@ public abstract class AbstractBTreeParti
             {
                 parentDn = entryDn.getParent();
 
+                lockRead();
+
                 try
                 {
-                    lockRead();
-
                     parentId = getEntryId( parentDn );
                 }
                 finally
@@ -723,10 +723,10 @@ public abstract class AbstractBTreeParti
             // Add the parentId in the entry
             entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
 
+            lockWrite();
+
             try
             {
-                lockWrite();
-
                 // Update the RDN index
                 rdnIdx.add( key, id );
 
@@ -777,9 +777,10 @@ public abstract class AbstractBTreeParti
             Dn dn = deleteContext.getDn();
             String id = null;
 
+            lockRead();
+
             try
             {
-                lockRead();
                 id = getEntryId( dn );
             }
             finally
@@ -880,9 +881,10 @@ public abstract class AbstractBTreeParti
             // First get the entry
             Entry entry = null;
 
+            lockRead();
+
             try
             {
-                lockRead();
                 entry = master.get( id );
             }
             finally
@@ -937,9 +939,10 @@ public abstract class AbstractBTreeParti
                 }
             }
 
+            lockWrite();
+
             try
             {
-                lockWrite();
                 rdnIdx.drop( id );
 
                 dumpRdnIdx();
@@ -1024,9 +1027,10 @@ public abstract class AbstractBTreeParti
      */
     public Entry fetch( String id ) throws LdapException
     {
+        lockRead();
+
         try
         {
-            lockRead();
             Dn dn = buildEntryDn( id );
     
             return fetch( id, dn );
@@ -1037,14 +1041,7 @@ public abstract class AbstractBTreeParti
         }
         finally
         {
-            try
-            {
-                unlockRead();
-            }
-            catch ( Exception e )
-            {
-                throw new LdapOperationErrorException( e.getMessage(), e );
-            }
+            unlockRead();
         }
     }
 
@@ -1072,9 +1069,10 @@ public abstract class AbstractBTreeParti
                 return new ClonedServerEntry( entry );
             }
             
+            lockRead();
+
             try
             {
-                lockRead();
                 entry = master.get( id );
             }
             finally
@@ -2716,7 +2714,7 @@ public abstract class AbstractBTreeParti
     /**
      * Acquire a Read lock
      */
-    private void lockRead() throws Exception
+    private void lockRead()
     {
         masterTableLock.readLock().lock();
     }
@@ -2725,7 +2723,7 @@ public abstract class AbstractBTreeParti
     /**
      * Release a Read lock
      */
-    private void unlockRead() throws Exception
+    private void unlockRead()
     {
         masterTableLock.readLock().unlock();
     }
@@ -2734,7 +2732,7 @@ public abstract class AbstractBTreeParti
     /**
      * Acquire a Write lock
      */
-    private void lockWrite() throws Exception
+    private void lockWrite()
     {
         masterTableLock.writeLock().lock();
     }
@@ -2743,7 +2741,7 @@ public abstract class AbstractBTreeParti
     /**
      * Release a Write lock
      */
-    private void unlockWrite() throws Exception
+    private void unlockWrite()
     {
         masterTableLock.writeLock().unlock();
     }



Mime
View raw message