jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1404936 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Fri, 02 Nov 2012 12:08:35 GMT
Author: mduerig
Date: Fri Nov  2 12:08:34 2012
New Revision: 1404936

URL: http://svn.apache.org/viewvc?rev=1404936&view=rev
Log:
 OAK-418: Reduce/avoid re-resolving the underlying tree instances on every access in Item/Property/NodeDelegate
 Removed items cannot be marked as such anymore since there might be several instances of
the "same" item now. Use underlying builder to determine whether a item has been removed.
FIXME this needs additional support from the underlying builder. See OAK-417.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1404936&r1=1404935&r2=1404936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Fri Nov  2 12:08:34 2012
@@ -59,9 +59,6 @@ public class TreeImpl implements Tree, P
     /** Parent of this tree. Null for the root. */
     private TreeImpl parent;
 
-    /** Marker for removed trees */
-    private boolean removed;
-
     /** Name of this tree */
     private String name;
 
@@ -295,7 +292,6 @@ public class TreeImpl implements Tree, P
         if (!isRoot() && parent.hasChild(name)) {
             NodeBuilder builder = parent.getNodeBuilder();
             builder.removeNode(name);
-            removed = true;
             if (parent.hasOrderableChildren()) {
                 builder.setProperty(
                         MemoryPropertyBuilder.create(Type.STRING, parent.internalGetProperty(OAK_CHILD_ORDER))
@@ -416,10 +412,6 @@ public class TreeImpl implements Tree, P
 
     @Nonnull
     protected synchronized NodeBuilder getNodeBuilder() {
-        if (isRemoved()) {
-            throw new IllegalStateException("Cannot get a builder for a removed tree");
-        }
-
         if (nodeBuilder == null) {
             nodeBuilder = parent.getNodeBuilder().child(name);
             root.addListener(this);
@@ -506,8 +498,20 @@ public class TreeImpl implements Tree, P
         return getNodeBuilder().getProperty(propertyName);
     }
 
+    // FIXME rely on underlying mechanism to determine whether a node has been removed. (OAK-417)
     private boolean isRemoved() {
-        return removed || (parent != null && parent.isRemoved());
+        if (parent != null && parent.isRemoved()) {
+            return true;
+        }
+        try {
+            if (nodeBuilder != null) {
+                nodeBuilder.getNodeState();
+            }
+            return false;
+        }
+        catch (IllegalStateException e) {
+            return true;
+        }
     }
 
     private void buildPath(StringBuilder sb) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1404936&r1=1404935&r2=1404936&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Fri Nov  2 12:08:34 2012
@@ -1042,6 +1042,18 @@ public class RepositoryTest extends Abst
     }
 
     @Test
+    public void removeNode2() throws RepositoryException {
+        Node foo = getNode("/foo");
+        getAdminSession().removeItem(foo.getPath());
+        try {
+            foo.getParent();
+            fail("Cannot retrieve the parent from a transiently removed item.");
+        } catch (InvalidItemStateException e) {
+            // success
+        }
+    }
+
+    @Test
     public void accessRemovedItem() throws RepositoryException {
         Node foo = getNode("/foo");
         Node bar = foo.addNode("bar");



Mime
View raw message