Author: mreutegg
Date: Wed Dec 16 13:37:30 2015
New Revision: 1720354
URL: http://svn.apache.org/viewvc?rev=1720354&view=rev
Log:
OAK-3733: Sometimes hierarchy conflict between concurrent add/delete isn't
detected
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1720354&r1=1720353&r2=1720354&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Wed Dec 16 13:37:30 2015
@@ -523,7 +523,8 @@ public class Commit {
String conflictMessage = null;
Revision conflictRevision = newestRev;
if (newestRev == null) {
- if ((op.isDelete() || !op.isNew()) && isConflicting(before,
op)) {
+ if ((op.isDelete() || !op.isNew())
+ && !allowConcurrentAddRemove(before, op)) {
conflictMessage = "The node " +
op.getId() + " does not exist or is already
deleted";
if (before != null && !before.getLocalDeleted().isEmpty())
{
@@ -531,7 +532,7 @@ public class Commit {
}
}
} else {
- if (op.isNew() && isConflicting(before, op)) {
+ if (op.isNew() && !allowConcurrentAddRemove(before, op)) {
conflictMessage = "The node " +
op.getId() + " was already added in revision\n" +
formatConflictRevision(newestRev);
@@ -616,6 +617,25 @@ public class Commit {
}
/**
+ * Checks whether a concurrent add/remove operation is allowed with the
+ * given before document and update operation. This method will first check
+ * if the concurrent add/remove feature is enable and return {@code false}
+ * immediately if it is disabled. Only when enabled will this method check
+ * if there is a conflict based on the given document and update operation.
+ * See also {@link #isConflicting(NodeDocument, UpdateOp)}.
+ *
+ * @param before the contents of the document before the update.
+ * @param op the update to perform.
+ * @return {@code true} is a concurrent add/remove update is allowed;
+ * {@code false} otherwise.
+ */
+ private boolean allowConcurrentAddRemove(@Nullable NodeDocument before,
+ @Nonnull UpdateOp op) {
+ return nodeStore.getEnableConcurrentAddRemove()
+ && !isConflicting(before, op);
+ }
+
+ /**
* @return the branch if this is a branch commit, otherwise {@code null}.
*/
@CheckForNull
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java?rev=1720354&r1=1720353&r2=1720354&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
Wed Dec 16 13:37:30 2015
@@ -22,7 +22,6 @@ package org.apache.jackrabbit.oak.plugin
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -43,7 +42,6 @@ public class CommitTest {
}
// OAK-3733
- @Ignore("OAK-3733")
@Test
public void detectConflict() throws Exception {
// prepare node store