jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r744911 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Date Mon, 16 Feb 2009 13:37:28 GMT
Author: jukka
Date: Mon Feb 16 13:37:19 2009
New Revision: 744911

URL: http://svn.apache.org/viewvc?rev=744911&view=rev
Log:
JCR-1979: Deadlock on concurrent read & transactional write operations

We can also move the other (than getReferences) virtual provider accesses outside the workspace
lock. This obsoletes the remaining parts of the "Use the JCR versioning API instead of the
/jcr:system/jcr:versionStorage tree to access version information" recommendation.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=744911&r1=744910&r2=744911&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Mon Feb 16 13:37:19 2009
@@ -243,29 +243,30 @@
      */
     public ItemState getItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
+        // check the virtual root ids (needed for overlay)
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].isVirtualRoot(id)) {
+                return virtualProviders[i].getItemState(id);
+            }
+        }
 
         ISMLocking.ReadLock readLock = acquireReadLock(id);
-
         try {
-            // check the virtual root ids (needed for overlay)
-            for (int i = 0; i < virtualProviders.length; i++) {
-                if (virtualProviders[i].isVirtualRoot(id)) {
-                    return virtualProviders[i].getItemState(id);
-                }
-            }
             // check internal first
             if (hasNonVirtualItemState(id)) {
                 return getNonVirtualItemState(id);
             }
-            // check if there is a virtual state for the specified item
-            for (int i = 0; i < virtualProviders.length; i++) {
-                if (virtualProviders[i].hasItemState(id)) {
-                    return virtualProviders[i].getItemState(id);
-                }
-            }
         } finally {
             readLock.release();
         }
+
+        // check if there is a virtual state for the specified item
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].hasItemState(id)) {
+                return virtualProviders[i].getItemState(id);
+            }
+        }
+
         throw new NoSuchItemStateException(id.toString());
     }
 
@@ -273,6 +274,12 @@
      * {@inheritDoc}
      */
     public boolean hasItemState(ItemId id) {
+        // check the virtual root ids (needed for overlay)
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].isVirtualRoot(id)) {
+                return true;
+            }
+        }
 
         ISMLocking.ReadLock readLock;
         try {
@@ -286,25 +293,21 @@
                 return true;
             }
 
-            // check the virtual root ids (needed for overlay)
-            for (int i = 0; i < virtualProviders.length; i++) {
-                if (virtualProviders[i].isVirtualRoot(id)) {
-                    return true;
-                }
-            }
             // check if this manager has the item state
             if (hasNonVirtualItemState(id)) {
                 return true;
             }
-            // otherwise check virtual ones
-            for (int i = 0; i < virtualProviders.length; i++) {
-                if (virtualProviders[i].hasItemState(id)) {
-                    return true;
-                }
-            }
         } finally {
             readLock.release();
         }
+
+        // otherwise check virtual ones
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].hasItemState(id)) {
+                return true;
+            }
+        }
+
         return false;
     }
 



Mime
View raw message