You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by li...@apache.org on 2008/12/22 17:43:15 UTC

svn commit: r728723 - /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java

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);
             } 
         }
     }