geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1076770 - in /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2: ./ geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/
Date Thu, 03 Mar 2011 20:08:24 GMT
Author: djencks
Date: Thu Mar  3 20:08:24 2011
New Revision: 1076770

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

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

Propchange: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar  3 20:08:24 2011
@@ -1,3 +1,3 @@
 /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1:981270
 /geronimo/components/txmanager/trunk:900557,911974,912058,912297,912468,939929,1028958,1058794,1058805
-/geronimo/sandbox/djencks/txmanager:1058803
+/geronimo/sandbox/djencks/txmanager:1058803,1073479

Propchange: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar  3 20:08:24 2011
@@ -1,3 +1,3 @@
 /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound:981270
 /geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound:900557,911974,912058,912297,912468,939929,1028958,1058794,1058805
-/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound:1058785,1058792,1058803
+/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound:1058785,1058792,1058803,1073479

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2/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.2/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=1076770&r1=1076769&r2=1076770&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Thu Mar  3 20:08:24 2011
@@ -57,6 +57,7 @@ public class TransactionImpl implements 
     private final IdentityHashMap<XAResource, TransactionBranch> activeXaResources
= new IdentityHashMap<XAResource, TransactionBranch>(3);
     private final IdentityHashMap<XAResource, TransactionBranch> suspendedXaResources
= new IdentityHashMap<XAResource, TransactionBranch>(3);
     private int status = Status.STATUS_NO_TRANSACTION;
+    private Exception markRollbackCause;
     private Object logMark;
 
     private final Map<Object, Object> resources = new HashMap<Object, Object>();
@@ -72,6 +73,7 @@ public class TransactionImpl implements 
         try {
             txManager.getTransactionLog().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);
@@ -255,19 +257,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, false);
-                if (timedout) {
-                    throw new RollbackException("Unable to commit: 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) {
@@ -432,6 +433,7 @@ public class TransactionImpl implements 
                     throw (SystemException) new SystemException("Error during prepare; transaction
was rolled back").initCause(e);
                 }
                 synchronized (this) {
+                    markRollbackCause(e);
                     status = Status.STATUS_MARKED_ROLLBACK;
                     /* Per JTA spec,  If the resource manager wants to roll back the transaction,
                     it should do so by throwing an appropriate XAException in the prepare
method.
@@ -521,12 +523,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);
@@ -570,6 +579,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