Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java (revision c88d9a4) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java (revision 021c8f4431f6136bb68b186841255a39e205d495) @@ -47,7 +47,6 @@ ItemDelegate(SessionDelegate sessionDelegate, TreeLocation location) { this.sessionDelegate = checkNotNull(sessionDelegate); this.location = checkNotNull(location); - this.revision = sessionDelegate.getRevision(); } /** @@ -83,8 +82,7 @@ * @return {@code true} iff stale */ public boolean isStale() { - Status status = getLocationOrNull().getStatus(); - return status == Status.DISCONNECTED || status == null; + return !getLocationInternal().exists(); } /** @@ -116,7 +114,7 @@ */ @Nonnull public TreeLocation getLocation() throws InvalidItemStateException { - TreeLocation location = getLocationOrNull(); + TreeLocation location = getLocationInternal(); if (!location.exists()) { throw new InvalidItemStateException("Item is stale"); } @@ -138,11 +136,8 @@ * @return tree location of the underlying item. */ @Nonnull - private synchronized TreeLocation getLocationOrNull() { - if (location.exists() && sessionDelegate.getRevision() != revision) { + private synchronized TreeLocation getLocationInternal() { - location = sessionDelegate.getLocation(location.getPath()); + location = sessionDelegate.getLocation(location.getPath()); - revision = sessionDelegate.getRevision(); - } return location; } Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java (revision c88d9a4) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java (revision 021c8f4431f6136bb68b186841255a39e205d495) @@ -86,7 +86,6 @@ private PrivilegeManager privilegeManager; private boolean isAlive = true; private int sessionOpCount; - private int revision; SessionDelegate( Repository repository, ScheduledExecutorService executor, @@ -147,16 +146,6 @@ (sessionOpCount <= 1 && observationManager != null && observationManager.hasEvents()); } - /** - * Revision of this session. The revision is incremented each time a session is refreshed or saved. - * This allows items to determine whether they need to re-resolve their underlying state when the - * revision on which an item is based does not match the revision of the session any more. - * @return the current revision of this session - */ - int getRevision() { - return revision; - } - public boolean isAlive() { return isAlive; } @@ -253,7 +242,6 @@ public void save() throws RepositoryException { try { root.commit(); - revision++; } catch (CommitFailedException e) { e.throwRepositoryException(); } @@ -265,7 +253,6 @@ } else { root.refresh(); } - revision++; } /** Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java (revision c88d9a4) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java (revision 021c8f4431f6136bb68b186841255a39e205d495) @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.jcr; +import javax.jcr.InvalidItemStateException; import javax.jcr.Node; import org.apache.jackrabbit.JcrConstants; @@ -35,46 +36,60 @@ } } - @Ignore("OAK-606") @Test public void testRename() throws Exception { Node node1 = testRootNode.addNode(nodeName1); superuser.save(); - String destPath = testRoot + '/' + nodeName2; - move(node1.getPath(), destPath, true); + String sourcePath = node1.getPath(); + move(sourcePath, testRoot + '/' + nodeName2, true); - assertEquals(destPath, node1.getPath()); + try { + node1.getPath(); + fail(); + } catch (InvalidItemStateException expected) {} + + testRootNode.addNode(nodeName1); + assertEquals(sourcePath, node1.getPath()); } - @Ignore("OAK-607") @Test public void testRenameNewNode() throws Exception { Node node1 = testRootNode.addNode(nodeName1); - String destPath = testRoot + '/' + nodeName2; - move(node1.getPath(), destPath, false); + String sourcePath = node1.getPath(); + move(sourcePath, testRoot + '/' + nodeName2, false); - assertEquals(destPath, node1.getPath()); + try { + node1.getPath(); + fail(); + } catch (InvalidItemStateException expected) {} + testRootNode.addNode(nodeName1); superuser.save(); - assertEquals(destPath, node1.getPath()); + assertEquals(sourcePath, node1.getPath()); } - @Ignore("OAK-606") @Test public void testMove() throws Exception { Node node1 = testRootNode.addNode(nodeName1); Node node2 = testRootNode.addNode(nodeName2); superuser.save(); - String destPath = node2.getPath() + '/' + nodeName1; - move(node1.getPath(), destPath, true); + String sourcePath = node1.getPath(); + move(sourcePath, node2.getPath() + '/' + nodeName1, true); - assertEquals(destPath, node1.getPath()); + try { + node1.getPath(); + fail(); + } catch (InvalidItemStateException expected) {} + + testRootNode.addNode(nodeName1); + assertEquals(sourcePath, node1.getPath()); } @Ignore("OAK-606") + @Test public void testMoveReferenceable() throws Exception { Node node1 = testRootNode.addNode(nodeName1); node1.addMixin(JcrConstants.MIX_REFERENCEABLE); @@ -87,19 +102,22 @@ assertEquals(destPath, node1.getPath()); } - @Ignore("OAK-607") @Test public void testMoveNewNode() throws Exception { Node node1 = testRootNode.addNode(nodeName1); Node node2 = testRootNode.addNode(nodeName2); - String destPath = node2.getPath() + '/' + nodeName1; - move(node1.getPath(), destPath, false); + String sourcePath = node1.getPath(); + move(sourcePath, node2.getPath() + '/' + nodeName1, false); - assertEquals(destPath, node1.getPath()); + try { + node1.getPath(); + fail(); + } catch (InvalidItemStateException expected) {} + testRootNode.addNode(nodeName1); superuser.save(); - assertEquals(destPath, node1.getPath()); + assertEquals(sourcePath, node1.getPath()); } @Ignore("OAK-607") \ No newline at end of file Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (revision c88d9a4) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (revision 021c8f4431f6136bb68b186841255a39e205d495) @@ -1627,6 +1627,7 @@ for (String parentPath : new String[] {"/", TEST_PATH}) { Node parent = session.getNode(parentPath); Node child = parent.addNode("child"); + String childPath = child.getPath(); child.remove(); try { @@ -1641,6 +1642,9 @@ fail(); } catch (InvalidItemStateException expected) { } + + parent.addNode("child"); + assertEquals(childPath, child.getPath()); } }