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 2015/04/16 17:12:47 UTC

svn commit: r1674090 - in /jackrabbit/oak/branches/1.2: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java

Author: mreutegg
Date: Thu Apr 16 15:12:46 2015
New Revision: 1674090

URL: http://svn.apache.org/r1674090
Log:
OAK-2780: DocumentMK.commit() does not check if node exists on property patch

Merged revision 1674075 from trunk

Modified:
    jackrabbit/oak/branches/1.2/   (props changed)
    jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java

Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 16 15:12:46 2015
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672834-1672835,1673351,1673410,1673436,1673644,1673662-1673664,1673669,1673695
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672834-1672835,1673351,1673410,1673436,1673644,1673662-1673664,1673669,1673695,1674075
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1674090&r1=1674089&r2=1674090&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java (original)
+++ jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java Thu Apr 16 15:12:46 2015
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.plugins.document;
 
 import java.io.InputStream;
+import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
@@ -27,6 +28,7 @@ import javax.sql.DataSource;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.Weigher;
+import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.mongodb.DB;
 
@@ -390,6 +392,7 @@ public class DocumentMK implements Micro
     private void parseJsonDiff(Commit commit, String json, String rootPath) {
         Revision baseRev = commit.getBaseRevision();
         String baseRevId = baseRev != null ? baseRev.toString() : null;
+        Set<String> added = Sets.newHashSet();
         JsopReader t = new JsopTokenizer(json);
         while (true) {
             int r = t.read();
@@ -402,6 +405,7 @@ public class DocumentMK implements Micro
                     t.read(':');
                     t.read('{');
                     parseAddNode(commit, t, path);
+                    added.add(path);
                     break;
                 case '-':
                     DocumentNodeState toRemove = nodeStore.getNode(path, commit.getBaseRevision());
@@ -421,6 +425,9 @@ public class DocumentMK implements Micro
                         value = t.readRawValue().trim();
                     }
                     String p = PathUtils.getParentPath(path);
+                    if (!added.contains(p) && nodeStore.getNode(p, commit.getBaseRevision()) == null) {
+                        throw new DocumentStoreException("Node not found: " + path + " in revision " + baseRevId);
+                    }
                     String propertyName = PathUtils.getName(path);
                     commit.updateProperty(p, propertyName, value);
                     commit.updatePropertyDiff(p, propertyName, value);