Author: tomekr
Date: Fri Jun  2 09:43:21 2017
New Revision: 1797351

URL: http://svn.apache.org/viewvc?rev=1797351&view=rev
Log:
OAK-6294: The "missing" node cache value breaks the 
DocumentNodeStore#applyChanges

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1797351&r1=1797350&r2=1797351&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
 Fri Jun  2 09:43:21 2017
@@ -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) {

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1797351&r1=1797350&r2=1797351&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
 Fri Jun  2 09:43:21 2017
@@ -3058,6 +3058,21 @@ public class DocumentNodeStoreTest {
         }
     }
 
+    // OAK-6294
+    @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<Boolean> createMulti = new ThreadLocal<>();
         int count;


Reply via email to