Commit fails even though change made it to the DocumentStore
Add ignored test
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -100,6 +101,61 @@ public class CommitRootUpdateTest {
assertFalse(throwAfterUpdate.get());
}
+ @Ignore
+ @Test
+ public void exceptionOnSingleUpdate() throws Exception {
+ final AtomicBoolean throwAfterUpdate = new AtomicBoolean(false);
+ MemoryDocumentStore store = new MemoryDocumentStore(true) {
+ @Override
+ public <T extends Document> T findAndUpdate(Collection<T> collection,
+ UpdateOp update) {
+ T doc = super.findAndUpdate(collection, update);
+ if (isCommitRootUpdate(update) &&
+ throwAfterUpdate.compareAndSet(true, false)) {
+ throw new DocumentStoreException("communication failure");
+ }
+ return doc;
+ }
+
+ private boolean isCommitRootUpdate(UpdateOp update) {
+ boolean isCommitRootUpdate = false;
+ for (Map.Entry<Key, Operation> op : update.getChanges().entrySet()) {
+ String name = op.getKey().getName();
+ if (NodeDocument.isRevisionsEntry(name)) {
+ isCommitRootUpdate = true;
+ break;
+ }
+ }
+ return isCommitRootUpdate;
+ }
+ };
+
+ DocumentNodeStore ns = builderProvider.newBuilder()
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+ NodeBuilder b = ns.getRoot().builder();
+ b.child("foo");
+ merge(ns, b);
+
+ throwAfterUpdate.set(true);
+ boolean success = false;
+ Commit c = ns.newCommit(ns.getHeadRevision(), null);
+ try {
+ c.updateProperty("/foo", "p", "v");
+ c.apply();
+ success = true;
+ } finally {
+ if (success) {
+ ns.done(c, false, CommitInfo.EMPTY);
+ } else {
+ ns.canceled(c);
+ }
+ }
+
+ NodeState root = ns.getRoot();
+ assertTrue(root.getChildNode("foo").hasProperty("p"));
+ assertFalse(throwAfterUpdate.get());
+ }
+
private NodeState merge(NodeStore store, NodeBuilder builder)
throws Exception {
return store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
