diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java index cc62b7f..c50262e 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java @@ -1387,6 +1387,9 @@ public final class DocumentNodeStore String p = PathUtils.getAncestorPath(path, depth - i); PathRev key = new PathRev(p, beforeState.getLastRevision()); beforeState = nodeCache.getIfPresent(key); + if (beforeState == missing) { + beforeState = null; + } } DocumentNodeState.Children children = null; if (beforeState != null) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java index 75f269e..80a0a3b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java @@ -3058,6 +3058,20 @@ public class DocumentNodeStoreTest { } } + @Test + public void missingLastRevInApplyChanges() throws CommitFailedException { + DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore(); + DocumentNodeState root = ns.getRoot(); + + RevisionVector before = root.getLastRevision(); + Revision rev = Revision.newRevision(1); + RevisionVector after = new RevisionVector(Revision.newRevision(1)); + + ns.getNode("/foo", before); + + ns.applyChanges(before, after, rev, "/foo", false, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); + } + private static class WriteCountingStore extends MemoryDocumentStore { private final ThreadLocal createMulti = new ThreadLocal<>(); int count;