geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1076789 - in /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1: ./ geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Date Thu, 03 Mar 2011 20:46:10 GMT
Author: djencks
Date: Thu Mar  3 20:46:10 2011
New Revision: 1076789

URL: http://svn.apache.org/viewvc?rev=1076789&view=rev
Log:
GERONIMO-4576 track and show the first exception from synchronizations

Modified:
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/   (props changed)
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java

Propchange: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/
------------------------------------------------------------------------------
    svn:mergeinfo = /geronimo/sandbox/djencks/txmanager:1073479

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.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.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=1076789&r1=1076788&r2=1076789&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Thu Mar  3 20:46:10 2011
@@ -61,6 +61,7 @@ public class TransactionImpl implements 
     private final IdentityHashMap activeXaResources = new IdentityHashMap(3);
     private final IdentityHashMap suspendedXaResources = new IdentityHashMap(3);
     private int status = Status.STATUS_NO_TRANSACTION;
+    private Exception markRollbackCause;
     private Object logMark;
 
     private final Map resources = new HashMap();
@@ -77,6 +78,7 @@ public class TransactionImpl implements 
         try {
             txnLog.begin(xid);
         } catch (LogException e) {
+            markRollbackCause(e);
             status = Status.STATUS_MARKED_ROLLBACK;
             SystemException ex = new SystemException("Error logging begin; transaction marked
for roll back)");
             ex.initCause(e);
@@ -257,19 +259,18 @@ public class TransactionImpl implements 
         beforePrepare();
 
         try {
-            boolean timedout = false;
             if (TransactionTimer.getCurrentTime() > timeout) {
+                markRollbackCause(new Exception("Transaction has timed out"));
                 status = Status.STATUS_MARKED_ROLLBACK;
-                timedout = true;
             }
 
             if (status == Status.STATUS_MARKED_ROLLBACK) {
                 rollbackResources(resourceManagers);
-                if (timedout) {
-                    throw new RollbackException("Transaction timeout");
-                } else {
-                    throw new RollbackException("Unable to commit: transaction marked for
rollback");
+                RollbackException rollbackException = new RollbackException("Unable to commit:
transaction marked for rollback");
+                if (markRollbackCause != null) {
+                    rollbackException.initCause(markRollbackCause);
                 }
+                throw rollbackException;
             }
             synchronized (this) {
                 if (status == Status.STATUS_ACTIVE) {
@@ -421,6 +422,7 @@ public class TransactionImpl implements 
                 }
             } catch (XAException e) {
                 synchronized (this) {
+                    markRollbackCause(e);
                     status = Status.STATUS_MARKED_ROLLBACK;
                     //TODO document why this is true from the spec.
                     //XAException during prepare means we can assume resource is rolled back.
@@ -515,12 +517,19 @@ public class TransactionImpl implements 
             } catch (Exception e) {
                 log.warn("Unexpected exception from beforeCompletion; transaction will roll
back", e);
                 synchronized (this) {
+                    markRollbackCause(e);
                     status = Status.STATUS_MARKED_ROLLBACK;
                 }
             }
         }
     }
 
+    private void markRollbackCause(Exception e) {
+        if (markRollbackCause == null) {
+            markRollbackCause = e;
+        }
+    }
+
     private void afterCompletion() {
         // this does not synchronize because nothing can modify our state at this time
         afterCompletion(interposedSyncList);
@@ -564,6 +573,7 @@ public class TransactionImpl implements 
             } catch (XAException e) {
                 log.warn("Error ending association for XAResource " + xaRes + "; transaction
will roll back. XA error code: " + e.errorCode, e);
                 synchronized (this) {
+                    markRollbackCause(e);
                     status = Status.STATUS_MARKED_ROLLBACK;
                 }
             }



Mime
View raw message