### Eclipse Workspace Patch 1.0 #P jackrabbit-core Index: src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (revision 1003402) +++ src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (working copy) @@ -1379,20 +1379,26 @@ 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; } /**