jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1000385 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java test/java/org/apache/jackrabbit/core/XATest.java
Date Thu, 23 Sep 2010 09:59:52 GMT
Author: jukka
Date: Thu Sep 23 09:59:52 2010
New Revision: 1000385

URL: http://svn.apache.org/viewvc?rev=1000385&view=rev
Log:
JCR-2712: Dirty Internal State on Transaction-Rollback during Global Transaction (container
managed transaction)

Make sure that the versioning lock covers an entire XA transaction
even when the transaction manager does not call prepare() before a
commit() or a rollback(). This also guarantees that proper cleanup
will happen during a rollback() without a preceding prepare().

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.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/version/InternalXAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java?rev=1000385&r1=1000384&r2=1000385&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
Thu Sep 23 09:59:52 2010
@@ -655,9 +655,17 @@ public class InternalXAVersionManager ex
             }
 
             public void commit(TransactionContext tx) {
+                // JCR-2712: Ensure that the transaction is prepared
+                if (!vmgrLocked) {
+                    prepare(tx);
+                }
             }
 
             public void rollback(TransactionContext tx) {
+                // JCR-2712: Ensure that the transaction is prepared
+                if (!vmgrLocked) {
+                    prepare(tx);
+                }
             }
 
             public void afterOperation(TransactionContext tx) {

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=1000385&r1=1000384&r2=1000385&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
Thu Sep 23 09:59:52 2010
@@ -30,6 +30,7 @@ import javax.jcr.version.VersionExceptio
 import javax.jcr.version.Version;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.NodeType;
 import javax.transaction.UserTransaction;
 import javax.transaction.RollbackException;
 import java.util.StringTokenizer;
@@ -105,6 +106,33 @@ public class XATest extends AbstractJCRT
     }
 
     /**
+     * Test case for
+     * <a href="https://issues.apache.org/jira/browse/JCR-2712">JCR-2712</a>.
+     */
+    public void testVersioningRollbackWithoutPrepare() throws Exception {
+        Session session = getHelper().getSuperuserSession();
+        try {
+            if (session.getRootNode().hasNode("testNode")) {
+                session.getRootNode().getNode("testNode").remove();
+                session.save();
+            }
+
+            UserTransaction utx;
+            for (int i = 0; i < 50; i++) {
+                utx = new UserTransactionImpl(session);
+                utx.begin();
+                session.getRootNode().addNode("testNode").addMixin(
+                        NodeType.MIX_VERSIONABLE);
+                session.save();
+
+                utx.rollback();
+            }
+        } finally {
+            session.logout();
+        }
+    }
+
+    /**
      * Add a node inside a transaction and commit changes. Make sure
      * node exists for other sessions only after commit.
      * @throws Exception



Mime
View raw message