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 mr...@apache.org on 2013/06/26 11:17:34 UTC

svn commit: r1496850 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java

Author: mreutegg
Date: Wed Jun 26 09:17:34 2013
New Revision: 1496850

URL: http://svn.apache.org/r1496850
Log:
OAK-881: KernelNodeState.processJsonDiff() does not propagate return value of NodeStateDiff

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1496850&r1=1496849&r2=1496850&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java Wed Jun 26 09:17:34 2013
@@ -429,8 +429,7 @@ public final class KernelNodeState exten
                             && childNodeCount > LOCAL_DIFF_THRESHOLD) {
                         // use MK.diff() when there are 'many' child nodes
                         String jsonDiff = kernel.diff(kbase.getRevision(), revision, path, 0);
-                        processJsonDiff(jsonDiff, kbase, diff);
-                        return true;
+                        return processJsonDiff(jsonDiff, kbase, diff);
                     }
                 }
             }
@@ -546,16 +545,20 @@ public final class KernelNodeState exten
      * @param jsonDiff the JSON diff.
      * @param base the base node state.
      * @param diff where diffs are reported to.
+     * @return {@code true} to continue the comparison, {@code false} to stop
      */
-    private void processJsonDiff(String jsonDiff,
+    private boolean processJsonDiff(String jsonDiff,
                                  KernelNodeState base,
                                  NodeStateDiff diff) {
         if (!hasChanges(jsonDiff)) {
-            return;
+            return true;
+        }
+        if (!comparePropertiesAgainstBaseState(base, diff)) {
+            return false;
         }
-        comparePropertiesAgainstBaseState(base, diff);
         JsopTokenizer t = new JsopTokenizer(jsonDiff);
-        while (true) {
+        boolean continueComparison = true;
+        while (continueComparison) {
             int r = t.read();
             if (r == JsopReader.END) {
                 break;
@@ -569,13 +572,13 @@ public final class KernelNodeState exten
                         // skip properties
                     }
                     String name = PathUtils.getName(path);
-                    diff.childNodeAdded(name, getChildNode(name));
+                    continueComparison = diff.childNodeAdded(name, getChildNode(name));
                     break;
                 }
                 case '-': {
                     String path = t.readString();
                     String name = PathUtils.getName(path);
-                    diff.childNodeDeleted(name, base.getChildNode(name));
+                    continueComparison = diff.childNodeDeleted(name, base.getChildNode(name));
                     break;
                 }
                 case '^': {
@@ -584,7 +587,7 @@ public final class KernelNodeState exten
                     if (t.matches('{')) {
                         t.read('}');
                         String name = PathUtils.getName(path);
-                        diff.childNodeChanged(name,
+                        continueComparison = diff.childNodeChanged(name,
                                 base.getChildNode(name), getChildNode(name));
                     } else if (t.matches('[')) {
                         // ignore multi valued property
@@ -602,9 +605,14 @@ public final class KernelNodeState exten
                     t.read(':');
                     String to = t.readString();
                     String fromName = PathUtils.getName(from);
-                    diff.childNodeDeleted(fromName, base.getChildNode(fromName));
+                    continueComparison = diff.childNodeDeleted(
+                            fromName, base.getChildNode(fromName));
+                    if (!continueComparison) {
+                        break;
+                    }
                     String toName = PathUtils.getName(to);
-                    diff.childNodeAdded(toName, getChildNode(toName));
+                    continueComparison = diff.childNodeAdded(
+                            toName, getChildNode(toName));
                     break;
                 }
                 default:
@@ -612,6 +620,7 @@ public final class KernelNodeState exten
                             + t.getToken() + "' at pos: " + t.getLastPos() + ' ' + jsonDiff);
             }
         }
+        return continueComparison;
     }
 
     private String getChildPath(String name) {