activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: [AMQ-3166] init rollbackonly exception cause such that xaexception has meaning, thanks to james (jtahlborn) for the suggestion
Date Tue, 22 Nov 2016 16:08:17 GMT
Repository: activemq
Updated Branches:
  refs/heads/master f40532a23 -> 7077d2b91


[AMQ-3166] init rollbackonly exception cause such that xaexception has meaning, thanks to
james (jtahlborn) for the suggestion


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/7077d2b9
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/7077d2b9
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/7077d2b9

Branch: refs/heads/master
Commit: 7077d2b910405dea7a60c5140824966ffebc66a8
Parents: f40532a
Author: gtully <gary.tully@gmail.com>
Authored: Tue Nov 22 16:07:28 2016 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Tue Nov 22 16:07:55 2016 +0000

----------------------------------------------------------------------
 .../org/apache/activemq/transaction/Transaction.java     | 11 ++++++-----
 .../test/java/org/apache/activemq/bugs/AMQ3166Test.java  |  4 +++-
 2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/7077d2b9/activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
b/activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
index 77710f3..13ec353 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/transaction/Transaction.java
@@ -44,7 +44,7 @@ public abstract class Transaction {
     public static final byte PREPARED_STATE = 2; // can go to: 3
     public static final byte FINISHED_STATE = 3;
     boolean committed = false;
-    boolean rollbackOnly = false;
+    Throwable rollackOnlyCause = null;
 
     private final ArrayList<Synchronization> synchronizations = new ArrayList<Synchronization>();
     private byte state = START_STATE;
@@ -111,9 +111,10 @@ public abstract class Transaction {
             throw xae;
         }
 
-        if (rollbackOnly) {
+        if (isRollbackOnly()) {
             XAException xae = newXAException("COMMIT FAILED: Transaction marked rollback
only", XAException.XA_RBROLLBACK);
             TransactionRolledBackException transactionRolledBackException = new TransactionRolledBackException(xae.getLocalizedMessage());
+            transactionRolledBackException.initCause(rollackOnlyCause);
             xae.initCause(transactionRolledBackException);
             throw xae;
         }
@@ -215,14 +216,14 @@ public abstract class Transaction {
     }
 
     public void setRollbackOnly(Throwable cause) {
-        if (!rollbackOnly) {
+        if (!isRollbackOnly()) {
             getLog().trace("setting rollback only, cause:", cause);
-            rollbackOnly = true;
+            rollackOnlyCause = cause;
         }
     }
 
     public boolean isRollbackOnly() {
-        return rollbackOnly;
+        return rollackOnlyCause != null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/7077d2b9/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3166Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3166Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3166Test.java
index 74e2d48..f72e034 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3166Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3166Test.java
@@ -51,7 +51,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-public class AMQ3166Test {
+public class   {
 
     private static final Logger LOG = LoggerFactory.getLogger(AMQ3166Test.class);
 
@@ -133,6 +133,8 @@ public class AMQ3166Test {
             fail("Expect TransactionRolledBackException");
         } catch (JMSException expected) {
             assertTrue(expected.getCause() instanceof XAException);
+            assertTrue(expected.getCause().getCause() instanceof TransactionRolledBackException);
+            assertTrue(expected.getCause().getCause().getCause() instanceof RuntimeException);
         }
 
         assertTrue("one message still there!", Wait.waitFor(new Wait.Condition() {


Mime
View raw message