You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2012/07/26 12:39:16 UTC

svn commit: r1365940 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java

Author: jukka
Date: Thu Jul 26 10:39:15 2012
New Revision: 1365940

URL: http://svn.apache.org/viewvc?rev=1365940&view=rev
Log:
OAK-167: Caching NodeStore implementation

Throw IllegalStateException when trying to access a builder for a node that has meanwhile been removed.
Kudos to Michi for the idea.

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java?rev=1365940&r1=1365939&r2=1365940&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java Thu Jul 26 10:39:15 2012
@@ -134,7 +134,9 @@ public class MemoryNodeStateBuilder impl
             if (pstate != null) {
                 MutableNodeState mstate = pstate.nodes.get(name);
                 if (mstate == null && pstate.nodes.containsKey(name)) {
-                    mstate = new MutableNodeState(NULL_STATE);
+                    throw new IllegalStateException(
+                            "This builder refers to a node that has"
+                            + " been removed from it's parent.");
                 }
                 if (mstate != null) {
                     parent = null;
@@ -153,11 +155,12 @@ public class MemoryNodeStateBuilder impl
             MutableNodeState mstate = pstate.nodes.get(name);
             if (mstate == null) {
                 if (pstate.nodes.containsKey(name)) {
-                    mstate = new MutableNodeState(NULL_STATE);
-                } else {
-                    mstate = new MutableNodeState(readState);
-                    pstate.nodes.put(name, mstate);
+                    throw new IllegalStateException(
+                            "This builder refers to a node that has"
+                            + " been removed from it's parent.");
                 }
+                mstate = new MutableNodeState(readState);
+                pstate.nodes.put(name, mstate);
             }
             parent = null;
             name = null;