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/08/19 16:00:50 UTC

svn commit: r1618866 - in /jackrabbit/oak/branches/1.0: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java

Author: mreutegg
Date: Tue Aug 19 14:00:50 2014
New Revision: 1618866

URL: http://svn.apache.org/r1618866
Log:
OAK-2020: NodeState view at given version is not stable with DocumentNodeStore

Merge revisions 1616719 and 1618613 from trunk

Added:
    jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java
      - copied, changed from r1616719, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java
Modified:
    jackrabbit/oak/branches/1.0/   (props changed)
    jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java

Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
  Merged /jackrabbit/oak/trunk:r1616719,1618613

Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1618866&r1=1618865&r2=1618866&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java Tue Aug 19 14:00:50 2014
@@ -106,7 +106,9 @@ class DocumentNodeState extends Abstract
         } else if (that instanceof DocumentNodeState) {
             DocumentNodeState other = (DocumentNodeState) that;
             if (getPath().equals(other.getPath())) {
-                return lastRevision.equals(other.lastRevision);
+                if (revisionEquals(other)) {
+                    return true;
+                }
             }
         } else if (that instanceof ModifiedNodeState) {
             ModifiedNodeState modified = (ModifiedNodeState) that;
@@ -244,7 +246,7 @@ class DocumentNodeState extends Abstract
             DocumentNodeState mBase = (DocumentNodeState) base;
             if (store == mBase.store) {
                 if (getPath().equals(mBase.getPath())) {
-                    if (lastRevision.equals(mBase.lastRevision)) {
+                    if (revisionEquals(mBase)) {
                         // no differences
                         return true;
                     } else {
@@ -372,6 +374,19 @@ class DocumentNodeState extends Abstract
 
     //------------------------------< internal >--------------------------------
 
+    /**
+     * Returns {@code true} if this state has the same revision as the
+     * {@code other} state. This method first compares the read {@link #rev}
+     * and then the {@link #lastRevision}.
+     *
+     * @param other the other state to compare with.
+     * @return {@code true} if the revisions are equal, {@code false} otherwise.
+     */
+    private boolean revisionEquals(DocumentNodeState other) {
+        return this.rev.equals(other.rev)
+                || this.lastRevision.equals(other.lastRevision);
+    }
+
     private boolean dispatch(@Nonnull String jsonDiff,
                              @Nonnull DocumentNodeState base,
                              @Nonnull NodeStateDiff diff) {

Copied: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java (from r1616719, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java?p2=jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java&r1=1616719&r2=1618866&rev=1618866&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java Tue Aug 19 14:00:50 2014
@@ -39,7 +39,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
@@ -58,7 +57,6 @@ public class NodeStoreDiffTest {
                 .getNodeStore();
     }
 
-    @Ignore("OAK-2020")
     @Test
     public void diffWithConflict() throws Exception{
         //Last rev on /var would be 1-0-1
@@ -95,7 +93,6 @@ public class NodeStoreDiffTest {
      * which are not affected by the commit
      * @throws Exception
      */
-    @Ignore("OAK-2020")
     @Test
     public void testDiff() throws Exception{
         createNodes("/oak:index/prop-a", "/oak:index/prop-b", "/etc/workflow");