geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r728724 - /geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Date Mon, 22 Dec 2008 16:45:44 GMT
Author: linsun
Date: Mon Dec 22 08:45:43 2008
New Revision: 728724

URL: http://svn.apache.org/viewvc?rev=728724&view=rev
Log:
GERONIMO-4478 enhance exception handling during transaction rollback + some message updates

Modified:
    geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java

Modified: geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=728724&r1=728723&r2=728724&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Mon Dec 22 08:45:43 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);
             } 
         }
     }



Mime
View raw message