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 15:46:58 UTC
svn commit: r1674075 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
Author: mreutegg
Date: Thu Apr 16 13:46:57 2015
New Revision: 1674075
URL: http://svn.apache.org/r1674075
Log:
OAK-2780: DocumentMK.commit() does not check if node exists on property patch
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1674075&r1=1674074&r2=1674075&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java Thu Apr 16 13:46:57 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;
@@ -372,6 +374,7 @@ public class DocumentMK {
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();
@@ -384,6 +387,7 @@ public class DocumentMK {
t.read(':');
t.read('{');
parseAddNode(commit, t, path);
+ added.add(path);
break;
case '-':
DocumentNodeState toRemove = nodeStore.getNode(path, commit.getBaseRevision());
@@ -403,6 +407,9 @@ public class DocumentMK {
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);