jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1453827 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Date Thu, 07 Mar 2013 12:49:14 GMT
Author: mduerig
Date: Thu Mar  7 12:49:14 2013
New Revision: 1453827

URL: http://svn.apache.org/r1453827
Log:
OAK-679: Allow read access to disconnected node builders
reverting changes as discussed for OAK-101

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.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=1453827&r1=1453826&r2=1453827&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
Thu Mar  7 12:49:14 2013
@@ -225,13 +225,13 @@ public class MemoryNodeBuilder implement
 
             return false;
         }
-        assert classInvariants();
-        return true;
+        return writeState != null || baseState != null;
     }
 
     @Nonnull
     private NodeState read() {
-        updateReadState();
+        checkState(updateReadState(), "This node has been removed or is disconnected");
+        assert classInvariants();
         return writeState != null ? writeState : baseState;
     }
 
@@ -473,8 +473,6 @@ public class MemoryNodeBuilder implement
         boolean modified = writeState != null && (writeState.base != baseState ||
writeState.nodes.containsKey(name));
         if (!hasBaseState(name) || modified) {
             builder.write(root.revision + 1, true);
-        } else {
-            builder.read();
         }
         return builder;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java?rev=1453827&r1=1453826&r2=1453827&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Thu Mar  7 12:49:14 2013
@@ -106,15 +106,14 @@ public class MemoryNodeBuilderTest {
         for (String name : new String[] {"x", "new"}) {
             NodeBuilder root = new MemoryNodeBuilder(BASE);
             NodeBuilder child = root.child(name);
-            child.child("q");
 
             root.removeNode(name);
-            assertEquals(1, child.getChildNodeCount());
-
             try {
-                child.setProperty("p", "v");
+                child.getChildNodeCount();
                 fail();
-            } catch (IllegalStateException expected) {}
+            } catch (IllegalStateException e) {
+                // expected
+            }
 
             root.child(name);
             assertEquals(0, child.getChildNodeCount()); // reconnect!
@@ -183,4 +182,14 @@ public class MemoryNodeBuilderTest {
         assertEquals(x.getBaseState(), x.getNodeState());
     }
 
+    @Test(expected = IllegalStateException.class)
+    public void testReadOnRemovedNode() {
+        NodeBuilder root = new MemoryNodeBuilder(BASE);
+        NodeBuilder m = root.child("m");
+        NodeBuilder n = m.child("n");
+
+        root.removeNode("m");
+        n.hasChildNode("any");
+    }
+
 }



Mime
View raw message