Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CFB49200BC5 for ; Tue, 22 Nov 2016 17:08:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CE680160B0C; Tue, 22 Nov 2016 16:08:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2191F160AF1 for ; Tue, 22 Nov 2016 17:08:18 +0100 (CET) Received: (qmail 92958 invoked by uid 500); 22 Nov 2016 16:08:18 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 92949 invoked by uid 99); 22 Nov 2016 16:08:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2016 16:08:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E244DDFFAB; Tue, 22 Nov 2016 16:08:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gtully@apache.org To: commits@activemq.apache.org Message-Id: <2b126694452f4dcdbbb7080c80a9167c@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) archived-at: Tue, 22 Nov 2016 16:08:20 -0000 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 Authored: Tue Nov 22 16:07:28 2016 +0000 Committer: gtully 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 synchronizations = new ArrayList(); 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() {