Author: manik.surtani(a)jboss.com
Date: 2009-01-23 06:18:14 -0500 (Fri, 23 Jan 2009)
New Revision: 7579
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/DummyBaseTransactionManager.java
Log:
JBCACHE-1469: DummyBaseTransactionManager behaves incorrectly with
Status.STATUS_MARKED_ROLLBACK
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/DummyBaseTransactionManager.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/transaction/DummyBaseTransactionManager.java 2009-01-23
09:00:21 UTC (rev 7578)
+++
core/trunk/src/main/java/org/jboss/cache/transaction/DummyBaseTransactionManager.java 2009-01-23
11:18:14 UTC (rev 7579)
@@ -39,7 +39,7 @@
*/
public class DummyBaseTransactionManager implements TransactionManager,
java.io.Serializable
{
- static ThreadLocal<Transaction> thread_local = new
ThreadLocal<Transaction>();
+ static ThreadLocal<DummyTransaction> thread_local = new
ThreadLocal<DummyTransaction>();
private static final long serialVersionUID = -6716097342564237376l;
/**
@@ -57,8 +57,10 @@
{
Transaction currentTx;
if ((currentTx = getTransaction()) != null)
+ {
throw new NotSupportedException(Thread.currentThread() +
" is already associated with a transaction (" + currentTx +
")");
+ }
DummyTransaction tx = new DummyTransaction(this);
setTransaction(tx);
}
@@ -90,13 +92,22 @@
IllegalStateException, SystemException
{
int status;
- Transaction tx = getTransaction();
+ DummyTransaction tx = getTransaction();
if (tx == null)
+ {
throw new IllegalStateException("thread not associated with
transaction");
+ }
status = tx.getStatus();
if (status == Status.STATUS_MARKED_ROLLBACK)
- throw new RollbackException();
- tx.commit();
+ {
+ tx.setStatus(Status.STATUS_ROLLEDBACK);
+ rollback();
+ throw new RollbackException("Transaction status is
Status.STATUS_MARKED_ROLLBACK");
+ }
+ else
+ {
+ tx.commit();
+ }
// Disassociate tx from thread.
setTransaction(null);
@@ -121,7 +132,9 @@
{
Transaction tx = getTransaction();
if (tx == null)
+ {
throw new IllegalStateException("no transaction associated with
thread");
+ }
tx.rollback();
// Disassociate tx from thread.
@@ -145,7 +158,9 @@
{
Transaction tx = getTransaction();
if (tx == null)
+ {
throw new IllegalStateException("no transaction associated with calling
thread");
+ }
tx.setRollbackOnly();
}
@@ -176,7 +191,7 @@
* If the transaction service fails in an
* unexpected way.
*/
- public Transaction getTransaction() throws SystemException
+ public DummyTransaction getTransaction() throws SystemException
{
return thread_local.get();
}
@@ -243,7 +258,7 @@
*/
public void setTransaction(Transaction tx)
{
- thread_local.set(tx);
+ thread_local.set((DummyTransaction) tx);
}
}
Show replies by date