jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r749965 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java
Date Wed, 04 Mar 2009 11:18:35 GMT
Author: jukka
Date: Wed Mar  4 11:18:35 2009
New Revision: 749965

URL: http://svn.apache.org/viewvc?rev=749965&view=rev
Log:
JCR-2000: Deadlock on concurrent commits

Create test nodes within a transaction to avoid mixing transactional and non-transactional
writes.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java?rev=749965&r1=749964&r2=749965&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java
Wed Mar  4 11:18:35 2009
@@ -46,6 +46,27 @@
      */
     private static final int NUM_OPERATIONS = 100;
 
+    /**
+     * Creates the named test node. The node is created within a transaction
+     * to avoid mixing transactional and non-transactional writes within a
+     * concurrent test run.
+     */
+    private static synchronized Node createParentNode(Node test, String name)
+            throws RepositoryException {
+        try {
+            UserTransaction utx = new UserTransactionImpl(test.getSession());
+            utx.begin();
+            Node parent = test.addNode(name);
+            test.save();
+            utx.commit();
+            return parent;
+        } catch (RepositoryException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RepositoryException("Failed to add node: " + name, e);
+        }
+    }
+
     public void testConcurrentAddVersionableInTransaction()
             throws RepositoryException {
         runTask(new Task() {
@@ -53,11 +74,7 @@
                     throws RepositoryException {
                 // add versionable nodes
                 final String threadName = Thread.currentThread().getName();
-                Node parent;
-                synchronized (ConcurrentVersioningWithTransactionsTest.class) {
-                    parent = test.addNode(threadName);
-                    test.save();
-                }
+                Node parent = createParentNode(test, threadName);
                 for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
                     try {
                         final UserTransaction utx = new UserTransactionImpl(test.getSession());



Mime
View raw message