Author: manik.surtani(a)jboss.com
Date: 2009-01-23 08:50:07 -0500 (Fri, 23 Jan 2009)
New Revision: 7590
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java
Log:
JBCACHE-1468: JBoss Cache ignores transactions with STATUS_MARKED_ROLLBACK and auto
commits data changes
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2009-01-23
13:43:02 UTC (rev 7589)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2009-01-23
13:50:07 UTC (rev 7590)
@@ -235,7 +235,6 @@
switch (status)
{
- case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ACTIVE:
case Status.STATUS_PREPARING:
break;
@@ -245,6 +244,8 @@
throw new IllegalStateException("already started committing. " +
this);
case Status.STATUS_COMMITTED:
throw new IllegalStateException("already committed. " + this);
+ case Status.STATUS_MARKED_ROLLBACK:
+ throw new RollbackException("already marked for rollback " +
this);
case Status.STATUS_ROLLING_BACK:
throw new RollbackException("already started rolling back. " +
this);
case Status.STATUS_ROLLEDBACK:
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-23
13:43:02 UTC (rev 7589)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2009-01-23
13:50:07 UTC (rev 7590)
@@ -359,33 +359,14 @@
}
/**
- * 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
+ * Returns true of tx's status is ACTIVE or PREPARING
*
* @param tx
* @return true if the tx is active or preparing
*/
public static boolean isValid(Transaction tx)
{
- return isActive(tx) || isPreparing(tx) || isMarkedAsRollback(tx);
+ return isActive(tx) || isPreparing(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-23
13:43:02 UTC (rev 7589)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/MarkAsRollbackTest.java 2009-01-23
13:50:07 UTC (rev 7590)
@@ -63,11 +63,17 @@
assert tm != null;
tm.begin();
tm.setRollbackOnly();
- cache.put(fqn, "k", "v");
- assert cache.get(fqn, "k").equals("v");
- assert cache.getRoot().getChildren().size() == 1;
try
{
+ cache.put(fqn, "k", "v");
+ assert false : "Should have failed";
+ }
+ catch (IllegalStateException expected)
+ {
+
+ }
+ try
+ {
tm.commit();
assert false : "Should have rolled back";
}