You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ck...@apache.org on 2013/08/21 10:15:54 UTC

svn commit: r1516109 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Author: ckoell
Date: Wed Aug 21 08:15:53 2013
New Revision: 1516109

URL: http://svn.apache.org/r1516109
Log:
JCR-3645 LockManagerImpl do not prevent the internal PathMap in all relevant Methods

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=1516109&r1=1516108&r2=1516109&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Wed Aug 21 08:15:53 2013
@@ -654,12 +654,17 @@ public class LockManagerImpl
     public void checkLock(Path path, Session session)
             throws LockException, RepositoryException {
 
-        PathMap.Element<LockInfo> element = lockMap.map(path, false);
-        LockInfo info = element.get();
-        if (info != null) {
-            if (element.hasPath(path) || info.isDeep()) {
-                checkLock(info, session);
+        acquire();
+        try {
+            PathMap.Element<LockInfo> element = lockMap.map(path, false);
+            LockInfo info = element.get();
+            if (info != null) {
+                if (element.hasPath(path) || info.isDeep()) {
+                    checkLock(info, session);
+                }
             }
+        } finally {
+            release();
         }
     }
 
@@ -688,18 +693,23 @@ public class LockManagerImpl
      */
     public void checkUnlock(Session session, NodeImpl node)
             throws LockException, RepositoryException {
-
-        // check whether node is locked by this session
-        PathMap.Element<LockInfo> element =
-            lockMap.map(getPath((SessionImpl) session, node.getId()), true);
-        if (element == null) {
-            throw new LockException("Node not locked: " + node);
-        }
-        LockInfo info = element.get();
-        if (info == null) {
-            throw new LockException("Node not locked: " + node);
+        acquire();
+        
+        try {
+            // check whether node is locked by this session
+            PathMap.Element<LockInfo> element =
+                lockMap.map(getPath((SessionImpl) session, node.getId()), true);
+            if (element == null) {
+                throw new LockException("Node not locked: " + node);
+            }
+            LockInfo info = element.get();
+            if (info == null) {
+                throw new LockException("Node not locked: " + node);
+            }
+            checkUnlock(info, session);
+        } finally {
+            release();
         }
-        checkUnlock(info, session);
     }
 
     /**
@@ -728,6 +738,8 @@ public class LockManagerImpl
      */
     public void addLockToken(SessionImpl session, String lt) throws LockException, RepositoryException {
         try {
+            acquire();
+            
             NodeId id = LockInfo.parseLockToken(lt);
 
             NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(id);
@@ -754,6 +766,8 @@ public class LockManagerImpl
             String msg = "Bad lock token: " + e.getMessage();
             log.warn(msg);
             throw new LockException(msg);
+        } finally {
+            release();
         }
     }
 
@@ -764,6 +778,8 @@ public class LockManagerImpl
             throws LockException, RepositoryException {
 
         try {
+            acquire();
+            
             NodeId id = LockInfo.parseLockToken(lt);
 
             NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(id);
@@ -787,6 +803,8 @@ public class LockManagerImpl
             String msg = "Bad lock token: " + e.getMessage();
             log.warn(msg);
             throw new LockException(msg);
+        } finally {
+            release();
         }
     }
 
@@ -1065,7 +1083,8 @@ public class LockManagerImpl
      * add and remove operations on nodes with the same UUID into a move
      * operation.
      */
-    private Iterator<HierarchyEvent> consolidateEvents(EventIterator events) {
+    @SuppressWarnings("unchecked")
+	private Iterator<HierarchyEvent> consolidateEvents(EventIterator events) {
         LinkedMap eventMap = new LinkedMap();
 
         while (events.hasNext()) {