You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ck...@apache.org on 2010/06/18 08:46:20 UTC
svn commit: r955852 - in /jackrabbit/trunk/jackrabbit-core/src:
main/java/org/apache/jackrabbit/core/NodeImpl.java
test/java/org/apache/jackrabbit/core/XATest.java
Author: ckoell
Date: Fri Jun 18 06:46:19 2010
New Revision: 955852
URL: http://svn.apache.org/viewvc?rev=955852&view=rev
Log:
JCR-2651 Unable to add/lock and unlock/remove Node with shared Session in 2 Transactions
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=955852&r1=955851&r2=955852&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Fri Jun 18 06:46:19 2010
@@ -314,7 +314,7 @@ public class NodeImpl extends ItemImpl i
// make transient (copy-on-write)
NodeState transientState =
stateMgr.createTransientNodeState(
- data.getNodeState(), ItemState.STATUS_EXISTING_MODIFIED);
+ (NodeState) stateMgr.getItemState(getId()), ItemState.STATUS_EXISTING_MODIFIED);
// replace persistent with transient state
data.setState(transientState);
} catch (ItemStateException ise) {
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=955852&r1=955851&r2=955852&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java Fri Jun 18 06:46:19 2010
@@ -1874,6 +1874,61 @@ public class XATest extends AbstractJCRT
other.save();
utx.commit();
}
+
+ /**
+ * Tests if it is possible to add-lock a node and unlock-remove it with
+ * a shared session in different transactions
+ * (see JCR-2341)
+ * @throws Exception
+ */
+ public void testAddLockTokenRemoveNode2() throws Exception {
+ // create new node and lock it
+ UserTransaction utx = new UserTransactionImpl(superuser);
+ utx.begin();
+
+ // add node that is both lockable and referenceable, save
+ Node rootNode = superuser.getRootNode();
+ Node n = rootNode.addNode(nodeName1);
+ n.addMixin(mixLockable);
+ n.addMixin(mixReferenceable);
+ rootNode.save();
+
+ String uuid = n.getUUID();
+
+ // lock this new node
+ Lock lock = n.lock(true, false);
+ String lockToken = lock.getLockToken();
+
+ // commit
+ utx.commit();
+
+
+ // refresh Lock Info
+ lock = n.getLock();
+
+ // start new Transaction and try to add lock token unlock the node and then remove it
+ utx = new UserTransactionImpl(superuser);
+ utx.begin();
+
+ Node otherNode = superuser.getNodeByUUID(uuid);
+ assertTrue("Node not locked", otherNode.isLocked());
+ // add lock token
+ superuser.addLockToken(lockToken);
+
+ // refresh Lock Info
+ lock = otherNode.getLock();
+
+ // assert: session must hold lock token
+ assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
+
+ otherNode.unlock();
+
+ assertFalse("Node is locked", otherNode.isLocked());
+
+ otherNode.remove();
+ superuser.save();
+ utx.commit();
+ }
/**
* Test setting the same property multiple times. Exposes an issue where