jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1404702 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Date Thu, 01 Nov 2012 18:11:40 GMT
Author: mduerig
Date: Thu Nov  1 18:11:40 2012
New Revision: 1404702

URL: http://svn.apache.org/viewvc?rev=1404702&view=rev
Log:
 OAK-418: Reduce/avoid re-resolving the underlying tree instances on every access in Item/Property/NodeDelegate

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java?rev=1404702&r1=1404701&r2=1404702&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Thu Nov  1 18:11:40 2012
@@ -24,6 +24,7 @@ import javax.jcr.InvalidItemStateExcepti
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.core.TreeImpl.NullLocation;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -75,7 +76,7 @@ public abstract class ItemDelegate {
      * @return  {@code true} iff stale
      */
     public boolean isStale() {
-        return getLocationOrNull() == null;
+        return getLocationOrNull() == NullLocation.INSTANCE;
     }
 
     /**
@@ -104,7 +105,7 @@ public abstract class ItemDelegate {
     @Nonnull
     public TreeLocation getLocation() throws InvalidItemStateException {
         TreeLocation location = getLocationOrNull();
-        if (location == null) {
+        if (location == NullLocation.INSTANCE) {
             throw new InvalidItemStateException("Item is stale");
         }
         return location;
@@ -124,21 +125,10 @@ public abstract class ItemDelegate {
      */
     @CheckForNull
     private synchronized TreeLocation getLocationOrNull() {
-        if (isStale(location)) {
-            return null;
-        }
-
-        location = sessionDelegate.getLocation(location.getPath());
-        return isStale(location) ? null : location;
-    }
-
-    private static boolean isStale(TreeLocation location) {
-        try {
-            return location.getStatus() == Status.REMOVED || location.getPath() == null;
-        }
-        catch (IllegalStateException e) {
-            return true; // FIXME left over from OAK-391. Find better way to determine staleness
(OAK-417, OAK-418)
+        if (location != NullLocation.INSTANCE) {
+            location = sessionDelegate.getLocation(location.getPath());
         }
+        return location;
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java?rev=1404702&r1=1404701&r2=1404702&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Thu Nov  1 18:11:40 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -112,7 +113,12 @@ public class CompatibilityIssuesTest ext
         Node sourceNode = session.getNode("/source/node");
         session.move("/source/node", "/target/moved");
         // assertEquals("/target/moved", sourceNode.getPath());  // passes on JR2, fails
on Oak
-        assertEquals("/source/node", sourceNode.getPath());      // fails on JR2, passed
on Oak
+        try {
+            sourceNode.getPath();
+        }
+        catch (InvalidItemStateException expected) {
+            // sourceNode is stale
+        }
     }
 
     @Test



Mime
View raw message