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/18 16:04:40 UTC
svn commit: r1618613 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java
Author: mreutegg
Date: Mon Aug 18 14:04:40 2014
New Revision: 1618613
URL: http://svn.apache.org/r1618613
Log:
OAK-2020: NodeState view at given version is not stable with DocumentNodeStore
Fix equals method and enable tests
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1618613&r1=1618612&r2=1618613&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java Mon Aug 18 14:04:40 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) {
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java?rev=1618613&r1=1618612&r2=1618613&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeStoreDiffTest.java Mon Aug 18 14:04:40 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");