jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1005043 - in /jackrabbit/branches/1.6: RELEASE-NOTES.txt jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Date Wed, 06 Oct 2010 13:59:38 GMT
Author: jukka
Date: Wed Oct  6 13:59:37 2010
New Revision: 1005043

URL: http://svn.apache.org/viewvc?rev=1005043&view=rev
Log:
JCR-2546: SISM blocks the item state cache when loading a new item

Patch backported by Tom Quellenberg.

Modified:
    jackrabbit/branches/1.6/RELEASE-NOTES.txt
    jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/branches/1.6/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.6/RELEASE-NOTES.txt?rev=1005043&r1=1005042&r2=1005043&view=diff
==============================================================================
--- jackrabbit/branches/1.6/RELEASE-NOTES.txt (original)
+++ jackrabbit/branches/1.6/RELEASE-NOTES.txt Wed Oct  6 13:59:37 2010
@@ -17,6 +17,7 @@ This release fixes the following issues:
 
   JCR-2341 Unable to add/lock and unlock/remove Node with shared Session ...
   JCR-2413 AlreadyClosedException on initial index creation
+  JCR-2546 SISM blocks the item state cache when loading a new item
   JCR-2579 InvalidItemStateException when attempting concurrent, non ...
   JCR-2598 Saving concurrent sessions executing random operations causes ...
   JCR-2613 NoSuchItemStateException on checkin after removeVersion in XA ...

Modified: jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1005043&r1=1005042&r2=1005043&view=diff
==============================================================================
--- jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed Oct  6 13:59:37 2010
@@ -1720,20 +1720,26 @@ public class SharedItemStateManager
     private ItemState getNonVirtualItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
 
-        // check cache; synchronized to ensure an entry is not created twice.
-        synchronized (cache) {
-            ItemState state = cache.retrieve(id);
-            if (state == null) {
-                // not found in cache, load from persistent storage
-                state = loadItemState(id);
-                state.setStatus(ItemState.STATUS_EXISTING);
-                // put it in cache
-                cache.cache(state);
-                // set parent container
-                state.setContainer(this);
-            }
-            return state;
+        ItemState state = cache.retrieve(id);
+        if (state == null) {
+        	synchronized (this) {
+        	    // Use a double check to ensure that the cache entry is
+                // not created twice. We don't synchronize the entire
+                // method to allow the first cache retrieval to proceed
+                // even when another thread is loading a new item state.
+        		state = cache.retrieve(id);
+        		if (state == null) {
+	                // not found in cache, load from persistent storage
+	                state = loadItemState(id);
+	                state.setStatus(ItemState.STATUS_EXISTING);
+	                // put it in cache
+	                cache.cache(state);
+	                // set parent container
+	                state.setContainer(this);
+        		}
+        	}
         }
+        return state;
     }
 
     /**



Mime
View raw message