[jbosscache-commits] JBoss Cache SVN: r7604 - in core/trunk/src: test/java/org/jboss/cache/transaction and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jan 27 18:06:55 EST 2009


Author: emmartins
Date: 2009-01-27 18:06:53 -0500 (Tue, 27 Jan 2009)
New Revision: 7604

Modified:
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
   core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java
Log:
final solution regarding issue JBCACHE-1468

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2009-01-27 18:01:32 UTC (rev 7603)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2009-01-27 23:06:53 UTC (rev 7604)
@@ -359,14 +359,33 @@
    }
 
    /**
-    * Returns true of tx's status is ACTIVE or PREPARING
+    * Returns true if transaction is STATUS_MARKED_ROLLBACK, false otherwise
+    */
+   public static boolean isMarkedAsRollback(Transaction tx)
+   {
+      if (tx == null) return false;
+      int status;
+      try
+      {
+         status = tx.getStatus();
+         return status == Status.STATUS_MARKED_ROLLBACK;
+      }
+      catch (SystemException e)
+      {
+         return false;
+      }
+   }
+
+
+   /**
+    * Returns true of tx's status is ACTIVE or PREPARING or MARKED_ROLLBACK
     *
     * @param tx
     * @return true if the tx is active or preparing
     */
    public static boolean isValid(Transaction tx)
    {
-      return isActive(tx) || isPreparing(tx);
+      return isActive(tx) || isPreparing(tx) || isMarkedAsRollback(tx);
    }
 
    /**

Modified: core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java	2009-01-27 18:01:32 UTC (rev 7603)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java	2009-01-27 23:06:53 UTC (rev 7604)
@@ -2,6 +2,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.UnitTestCacheFactory;
@@ -51,7 +52,7 @@
          TestingUtil.killCaches(cache);
       }
    }
-
+   
    public void testMarkAsRollbackBeforeMods() throws Exception
    {
       Configuration c = new Configuration();
@@ -68,9 +69,9 @@
             cache.put(fqn, "k", "v");
             assert false : "Should have failed";
          }
-         catch (IllegalStateException expected)
+         catch (CacheException expected)
          {
-
+        	 assert expected.getCause() instanceof RollbackException : "exception wrapped and thrown should be RollbackException. Exception class "+expected.getCause().getClass();
          }
          try
          {




More information about the jbosscache-commits mailing list