Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 42242 invoked from network); 22 Dec 2008 16:43:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Dec 2008 16:43:46 -0000 Received: (qmail 58710 invoked by uid 500); 22 Dec 2008 16:43:45 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 58568 invoked by uid 500); 22 Dec 2008 16:43:45 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 58559 invoked by uid 99); 22 Dec 2008 16:43:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2008 08:43:45 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2008 16:43:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 046982388979; Mon, 22 Dec 2008 08:43:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r728723 - /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Date: Mon, 22 Dec 2008 16:43:15 -0000 To: scm@geronimo.apache.org From: linsun@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081222164316.046982388979@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: linsun Date: Mon Dec 22 08:43:14 2008 New Revision: 728723 URL: http://svn.apache.org/viewvc?rev=728723&view=rev Log: GERONIMO-4478 enhance exception handling during transaction rollback + some message updates Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=728723&r1=728722&r2=728723&view=diff ============================================================================== --- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java (original) +++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Mon Dec 22 08:43:14 2008 @@ -262,12 +262,12 @@ if (TransactionTimer.getCurrentTime() > timeout) { status = Status.STATUS_MARKED_ROLLBACK; timedout = true; - } + } if (status == Status.STATUS_MARKED_ROLLBACK) { rollbackResourcesDuringCommit(resourceManagers, false); if (timedout) { - throw new RollbackException("Transaction timeout"); + throw new RollbackException("Unable to commit: Transaction timeout"); } else { throw new RollbackException("Unable to commit: transaction marked for rollback"); } @@ -596,17 +596,25 @@ synchronized (this) { status = Status.STATUS_ROLLING_BACK; } - for (Iterator i = rms.iterator(); i.hasNext();) { - TransactionBranch manager = (TransactionBranch) i.next(); - try { - manager.getCommitter().rollback(manager.getBranchId()); - } catch (XAException e) { - log.error("Unexpected exception rolling back " + manager.getCommitter() + "; continuing with rollback", e); - if (cause == null) { - cause = new SystemException(e.errorCode); + try { + for (Iterator i = rms.iterator(); i.hasNext();) { + TransactionBranch manager = (TransactionBranch) i.next(); + try { + manager.getCommitter().rollback(manager.getBranchId()); + } catch (XAException e) { + log.error("Unexpected exception rolling back " + manager.getCommitter() + "; continuing with rollback", e); + if (e.errorCode == XAException.XA_HEURRB) { + // let's not set the cause here + log.info("Transaction has been heuristically rolled back " + manager.getCommitter() + "; continuing with rollback", e); + manager.getCommitter().forget(manager.getBranchId()); + } else if (cause == null) { + cause = new SystemException(e.errorCode); + } } } - } + } catch (XAException e) { + throw (SystemException) new SystemException("Error during rolling back").initCause(e); + } synchronized (this) { status = Status.STATUS_ROLLEDBACK; @@ -630,7 +638,7 @@ everRolledback = true; } catch (XAException e) { if (e.errorCode == XAException.XA_HEURRB) { - // let's not set the cause here + // let's not set the cause here as the resulting behavior is same as requested behavior log.error("Transaction has been heuristically rolled back " + manager.getCommitter() + "; continuing with rollback", e); everRolledback = true; manager.getCommitter().forget(manager.getBranchId()); @@ -649,7 +657,7 @@ } } } catch (XAException e) { - throw (SystemException) new SystemException("Error during rolling back").initCause(e); + throw (SystemException) new SystemException("System error during commit/rolling back").initCause(e); } synchronized (this) { @@ -657,14 +665,14 @@ } if (cause == null) { - throw (RollbackException) new RollbackException("Error during two phase commit").initCause(cause); + throw (RollbackException) new RollbackException("Unable to commit: transaction marked for rollback").initCause(cause); } else { if (cause.errorCode == XAException.XA_HEURCOM && everRolledback) { - throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause); + throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause); } else if (cause.errorCode == XAException.XA_HEURMIX) { - throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause); + throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause); } else { - throw (SystemException) new SystemException("Error during two phase commit").initCause(cause); + throw (SystemException) new SystemException("System Error during commit/rolling back").initCause(cause); } } }