db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/odmg TransactionImpl.java
Date Thu, 16 Oct 2003 17:10:52 GMT
arminw      2003/10/16 10:10:52

  Modified:    src/java/org/apache/ojb/odmg TransactionImpl.java
  Log:
  fix bug posted by Dave Derry,
  he wrote:
  
  However, there is a problem rollingback if there is a problem
  in the TransactionImpl#commit.
  
  Code for our Transaction#abort looks something like this
  
              if (tx != null && tx.isOpen())
              {    tx.abort();   }
  
  along with some other processing. But if OJB has rolledback the transaction, this
  test will pass, but the tx.abort() will throw an Exception.
  
  The problem here is that in TransactionImpl#commit(), if an Exception occurs, the
  status is set to STATUS_MARKED_ROLLBACK, and doAbort() is called. I believe that
  abort() should be called instead. Calling abort() would result in the status
  being set to STATUS_ROLLEDBACK, which would cause the tx.isOpen() test to fail.
  In addition, PersistenceBroker#abortTransaction() would be called, which would
  trigger the aborted transaction Listener events.
  
  Revision  Changes    Path
  1.48      +9 -9      db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TransactionImpl.java	4 Oct 2003 17:48:00 -0000	1.47
  +++ TransactionImpl.java	16 Oct 2003 17:10:51 -0000	1.48
  @@ -620,14 +620,7 @@
           {
               m_txStatus = Status.STATUS_MARKED_ROLLBACK;
               if (log.isDebugEnabled()) log.debug("Commit fails, do abort this tx", ex);
  -            try
  -            {
  -                doAbort();
  -            }
  -            finally
  -            {
  -                doClose();
  -            }
  +            abort();
               throw ex;
           }
       }
  @@ -684,6 +677,13 @@
        */
       public void abort()
       {
  +        /*
  +        do nothing if already rolledback
  +        */
  +        if(m_txStatus == Status.STATUS_ROLLEDBACK)
  +        {
  +            return;
  +        }
           if (m_txStatus != Status.STATUS_ACTIVE && m_txStatus != Status.STATUS_PREPARED
&&
                   m_txStatus != Status.STATUS_MARKED_ROLLBACK)
               throw new IllegalStateException("persist.noTransaction");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message