User: sparre  
  Date: 01/06/19 16:14:19

  Modified:    src/main/org/jboss/tm TxManager.java
  Log:
  More isDone() checking needed for a consistent view of transaction state
  between Transaction and TransactionManager.
  
  Revision  Changes    Path
  1.30      +47 -25    jboss/src/main/org/jboss/tm/TxManager.java
  
  Index: TxManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/tm/TxManager.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- TxManager.java    2001/06/18 20:01:28     1.29
  +++ TxManager.java    2001/06/19 23:14:19     1.30
  @@ -36,7 +36,7 @@
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.29 $
  + *  @version $Revision: 1.30 $
    */
   public class TxManager
      implements TransactionManager,
  @@ -92,9 +92,13 @@
   
         TransactionImpl current = ti.tx;
   
  -      if (current != null && !current.isDone())
  -         throw new NotSupportedException("Transaction already active, " +
  -                                         "cannot nest transactions.");
  +      if (current != null) {
  +         if (current.isDone())
  +            ti.tx = null;
  +         else
  +            throw new NotSupportedException("Transaction already active, " +
  +                                            "cannot nest transactions.");
  +      }
   
         long timeout = (ti.timeout == 0) ? timeOut : ti.timeout;
         TxCapsule txCapsule = TxCapsule.getInstance(timeout);
  @@ -132,12 +136,16 @@
      public int getStatus()
         throws SystemException
      {
  -      TransactionImpl current = getTxImpl();
  +      ThreadInfo ti = getThreadInfo();
  +      TransactionImpl current = ti.tx;
   
  -      if (current != null)
  -         return current.getStatus();
  -      else
  -         return Status.STATUS_NO_TRANSACTION;
  +      if (current != null) {
  +         if (current.isDone())
  +            ti.tx = null;
  +         else
  +            return current.getStatus();
  +      }
  +      return Status.STATUS_NO_TRANSACTION;
      }
   
      /**
  @@ -150,10 +158,9 @@
         ThreadInfo ti = getThreadInfo();
         TransactionImpl current = ti.tx;
   
  -      if (current != null && current.isDone()) {
  -         ti.tx = null;
  -         return null;
  -      }
  +      if (current != null && current.isDone())
  +         current = ti.tx = null;
  +
         return current;
      }
   
  @@ -176,8 +183,12 @@
         ThreadInfo ti = getThreadInfo();
         TransactionImpl current = ti.tx;
           
  -      if (current != null)
  -         throw new IllegalStateException("Already associated with a tx");
  +      if (current != null) {
  +         if (current.isDone())
  +            current = ti.tx = null;
  +         else
  +            throw new IllegalStateException("Already associated with a tx");
  +      }
   
         if (current != transaction)
            ti.tx = (TransactionImpl)transaction;
  @@ -197,9 +208,12 @@
         ThreadInfo ti = getThreadInfo();
         TransactionImpl current = ti.tx;
           
  -      if (current != null)
  +      if (current != null) {
            ti.tx = null;
  -        
  +         if (current.isDone())
  +            current = null;
  +      }
  +
         return current;
      }
   
  @@ -215,10 +229,13 @@
         TransactionImpl current = ti.tx;
   
         if (current != null) {
  -         current.rollback();
  +         if (!current.isDone()) {
  +            current.rollback();
  +            return;
  +         }
            ti.tx = null;
  -      } else
  -         throw new IllegalStateException("No transaction.");
  +      }
  +      throw new IllegalStateException("No transaction.");
      }
   
      /**
  @@ -229,12 +246,17 @@
         throws IllegalStateException,
                SystemException
      {
  -      TransactionImpl current = getTxImpl();
  +      ThreadInfo ti = getThreadInfo();
  +      TransactionImpl current = ti.tx;
   
  -      if (current != null)
  -         current.setRollbackOnly();
  -      else
  -         throw new IllegalStateException("No transaction.");
  +      if (current != null) {
  +         if (!current.isDone()) {
  +            current.setRollbackOnly();
  +            return;
  +         }
  +         ti.tx = null;
  +      }
  +      throw new IllegalStateException("No transaction.");
      }
   
      /**
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to