jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r191092 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ItemManager.java state/LocalItemStateManager.java state/SharedItemStateManager.java
Date Fri, 17 Jun 2005 06:42:20 GMT
Author: tripod
Date: Thu Jun 16 23:42:18 2005
New Revision: 191092

URL: http://svn.apache.org/viewcvs?rev=191092&view=rev
Log:
[JCR-136] Cached item could be lost in cache

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java?rev=191092&r1=191091&r2=191092&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java Thu Jun
16 23:42:18 2005
@@ -275,9 +275,7 @@
             // check privileges
             if (!session.getAccessManager().isGranted(id, AccessManager.READ)) {
                 // clear cache
-                if (isCached(id)) {
-                    evictItem(id);
-                }
+                evictItem(id);
                 // item exists but the session has not been granted read access
                 return false;
             }
@@ -310,9 +308,7 @@
             // check privileges
             if (!session.getAccessManager().isGranted(id, AccessManager.READ)) {
                 // clear cache
-                if (isCached(id)) {
-                    evictItem(id);
-                }
+                evictItem(id);
                 // item exists but the session has not been granted read access
                 return false;
             }
@@ -362,24 +358,22 @@
         // check privileges
         if (!session.getAccessManager().isGranted(id, AccessManager.READ)) {
             // clear cache
-            if (isCached(id)) {
-                evictItem(id);
-            }
+            evictItem(id);
             throw new AccessDeniedException("cannot read item " + id);
         }
 
         // check cache
-        if (isCached(id)) {
-            return retrieveItem(id);
-        }
-
-        // shortcut
-        if (id.denotesNode() && id.equals(rootNodeId)) {
-            return getRoot();
+        ItemImpl item = retrieveItem(id);
+        if (item == null) {
+            // shortcut
+            if (id.denotesNode() && id.equals(rootNodeId)) {
+                item = getRoot();
+            } else {
+                // create instance of item using its state object
+                item = createItemInstance(id);
+            }
         }
-
-        // create instance of item using its state object
-        return createItemInstance(id);
+        return item;
     }
 
     /**
@@ -592,15 +586,6 @@
     }
 
     //---------------------------------------------------< item cache methods >
-    /**
-     * Checks if there's a cache entry for the specified id.
-     *
-     * @param id the id to be checked
-     * @return true if there's a corresponding cache entry, otherwise false.
-     */
-    private boolean isCached(ItemId id) {
-        return itemCache.containsKey(id);
-    }
 
     /**
      * Returns an item reference from the cache.

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=191092&r1=191091&r2=191092&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Thu Jun 16 23:42:18 2005
@@ -160,16 +160,16 @@
 
         // check cache. synchronized to ensure an entry is not created twice.
         synchronized (cacheMonitor) {
-            if (isCached(id)) {
-                return retrieve(id);
-            }
-
-            // regular behaviour
-            if (id.denotesNode()) {
-                return getNodeState((NodeId) id);
-            } else {
-                return getPropertyState((PropertyId) id);
+            state = retrieve(id);
+            if (state == null) {
+                // regular behaviour
+                if (id.denotesNode()) {
+                    state = getNodeState((NodeId) id);
+                } else {
+                    state = getPropertyState((PropertyId) id);
+                }
             }
+            return state;
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=191092&r1=191091&r2=191092&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Thu Jun 16 23:42:18 2005
@@ -254,14 +254,16 @@
 
         // check cache. synchronized to ensure an entry is not created twice.
         synchronized (cacheMonitor) {
-            if (isCached(id)) {
-                return retrieve(id);
-            }
-            if (id.denotesNode()) {
-                return getNodeState((NodeId) id);
-            } else {
-                return getPropertyState((PropertyId) id);
+            ItemState state = retrieve(id);
+            if (state == null) {
+                // regular behaviour
+                if (id.denotesNode()) {
+                    state = getNodeState((NodeId) id);
+                } else {
+                    state = getPropertyState((PropertyId) id);
+                }
             }
+            return state;
         }
     }
 



Mime
View raw message