jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1424213 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
Date Wed, 19 Dec 2012 23:12:53 GMT
Author: mduerig
Date: Wed Dec 19 23:12:52 2012
New Revision: 1424213

URL: http://svn.apache.org/viewvc?rev=1424213&view=rev
Log:
OAK-531: NodeBuilder deleted child nodes can come back
No need to traverse the parent hierarchy. Just correctly check whether a node has been removed
from the parent builder by checking whether it is present in the base state but not present
in the write state.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1424213&r1=1424212&r2=1424213&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
Wed Dec 19 23:12:52 2012
@@ -187,11 +187,21 @@ public class MemoryNodeBuilder implement
         }
     }
 
+    /**
+     * Determine whether this child has been removed.
+     * Assumes {@code read()}, {@code write()} needs not be called.
+     * @return  {@code true} iff this child has been removed
+     */
+    private boolean removed() {
+        return !isRoot() && parent.writeState != null &&
+                parent.hasBaseState(name) && !parent.writeState.hasChildNode(name);
+    }
+
     @Nonnull
     private NodeState read() {
         if (revision != root.revision) {
             assert(!isRoot()); // root never gets here since revision == root.revision
-            checkState(!isRemoved(), "This node has already been removed");
+            checkState(!removed(), "This node has already been removed");
             parent.read();
 
             // The builder could have been reset, need to re-get base state
@@ -221,7 +231,7 @@ public class MemoryNodeBuilder implement
     private MutableNodeState write(long newRevision, boolean skipRemovedCheck) {
         // make sure that all revision numbers up to the root gets updated
         if (!isRoot()) {
-            checkState(skipRemovedCheck || !isRemoved());
+            checkState(skipRemovedCheck || !removed());
             parent.write(newRevision, skipRemovedCheck);
         }
 
@@ -233,7 +243,7 @@ public class MemoryNodeBuilder implement
 
             writeState = parent.getWriteState(name);
             if (writeState == null) {
-                if (isRemoved()) {
+                if (removed()) {
                     writeState = new MutableNodeState(null);
                 }
                 else {



Mime
View raw message