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 2014/11/25 22:26:05 UTC

svn commit: r1641700 - in /jackrabbit/oak/branches/1.0: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java

Author: mreutegg
Date: Tue Nov 25 21:26:04 2014
New Revision: 1641700

URL: http://svn.apache.org/r1641700
Log:
OAK-2288: DocumentNS may expose branch commit on earlier revision

Merged revision 1641695 from trunk

Modified:
    jackrabbit/oak/branches/1.0/   (props changed)
    jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
    jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java

Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
  Merged /jackrabbit/oak/trunk:r1641695

Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java?rev=1641700&r1=1641699&r2=1641700&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java Tue Nov 25 21:26:04 2014
@@ -1519,9 +1519,6 @@ public final class NodeDocument extends 
                                 @Nonnull Revision revision,
                                 @Nullable String commitValue,
                                 @Nonnull Revision readRevision) {
-        if (revision.equalsIgnoreBranch(readRevision)) {
-            return true;
-        }
         if (commitValue == null) {
             commitValue = getCommitValue(revision);
         }

Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1641700&r1=1641699&r2=1641700&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Tue Nov 25 21:26:04 2014
@@ -49,6 +49,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 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.apache.jackrabbit.oak.stats.Clock;
 import org.junit.After;
 import org.junit.Test;
@@ -618,6 +619,46 @@ public class DocumentNodeStoreTest {
         ns2.dispose();
     }
 
+    // OAK-2288
+    @Test
+    public void mergedBranchVisibility() throws Exception {
+        final DocumentNodeStore store = new DocumentMK.Builder()
+                .setAsyncDelay(0).getNodeStore();
+        DocumentStore docStore = store.getDocumentStore();
+
+        NodeBuilder builder1 = store.getRoot().builder();
+        builder1.child("test");
+        merge(store, builder1);
+
+        builder1 = store.getRoot().builder();
+        NodeBuilder node = builder1.getChildNode("test").child("node");
+        String id = Utils.getIdFromPath("/test/node");
+        int i = 0;
+        // force creation of a branch
+        while (docStore.find(NODES, id) == null) {
+            node.setProperty("foo", i++);
+        }
+
+        NodeDocument doc = docStore.find(NODES, id);
+        assertNotNull(doc);
+        Revision rev = doc.getLocalDeleted().firstKey();
+
+        merge(store, builder1);
+
+        // must not be visible at the revision of the branch commit
+        assertFalse(store.getRoot(rev).getChildNode("test").getChildNode("node").exists());
+
+        // must be visible at the revision of the merged branch
+        assertTrue(store.getRoot().getChildNode("test").getChildNode("node").exists());
+
+        store.dispose();
+    }
+
+    private static void merge(NodeStore store, NodeBuilder root)
+            throws CommitFailedException {
+        store.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+    }
+
     private static class TestHook extends EditorHook {
 
         TestHook(final String prefix) {