jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1493222 - 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 Fri, 14 Jun 2013 19:24:59 GMT
Author: mduerig
Date: Fri Jun 14 19:24:59 2013
New Revision: 1493222

URL: http://svn.apache.org/r1493222
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder
Disallow removing root node. Avoid NPE

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=1493222&r1=1493221&r2=1493222&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
Fri Jun 14 19:24:59 2013
@@ -269,7 +269,7 @@ public class MemoryNodeBuilder implement
 
     @Override
     public boolean remove() {
-        if (exists()) {
+        if (!isRoot() && exists()) {
             head().getMutableNodeState();  // Make sure the removed node is connected
             parent.head().getMutableNodeState().removeChildNode(name);
             return true;

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=1493222&r1=1493221&r2=1493222&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
Fri Jun 14 19:24:59 2013
@@ -447,6 +447,11 @@ public class MemoryNodeBuilderTest {
         assertTrue(c.hasProperty("c2"));
     }
 
+    @Test
+    public void removeRoot() {
+        assertFalse(base.builder().remove());
+    }
+
     private static NodeState createBC(final boolean exists) {
         final NodeState C = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE)
             .setProperty("c", "cValue")



Mime
View raw message