Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 99216 invoked from network); 16 Oct 2003 17:10:54 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 16 Oct 2003 17:10:54 -0000 Received: (qmail 75552 invoked by uid 500); 16 Oct 2003 17:10:46 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 75331 invoked by uid 500); 16 Oct 2003 17:10:44 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 75318 invoked by uid 500); 16 Oct 2003 17:10:44 -0000 Received: (qmail 75315 invoked from network); 16 Oct 2003 17:10:44 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 16 Oct 2003 17:10:44 -0000 Received: (qmail 99200 invoked by uid 1510); 16 Oct 2003 17:10:52 -0000 Date: 16 Oct 2003 17:10:52 -0000 Message-ID: <20031016171052.99199.qmail@minotaur.apache.org> From: arminw@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/odmg TransactionImpl.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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