From f29ab8372711f9fa66dfa2f8e44229d99a807876 Mon Sep 17 00:00:00 2001 From: Tom Ross Date: Mon, 7 Dec 2015 17:57:43 +0000 Subject: [PATCH] NullPointerException when trying to list prepared transactions as JSON --- .../artemis/core/transaction/TransactionDetail.java | 8 +++++++- .../artemis/core/transaction/impl/TransactionImpl.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java index 751f35ff90..068b15f04c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java @@ -72,7 +72,13 @@ public abstract class TransactionDetail { detailJson.put(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier())); JSONArray msgsJson = new JSONArray(); - List txops = this.transaction.getAllOperations(); + + List txops = null; + + if (this.transaction != null) { + txops = this.transaction.getAllOperations(); + } + detailJson.put(KEY_TX_RELATED_MESSAGES, msgsJson); if (txops == null) { return detailJson; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java index 6ff65657ce..c84e6f00a4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java @@ -392,7 +392,13 @@ public class TransactionImpl implements Transaction { @Override public synchronized List getAllOperations() { - return new ArrayList(operations); + + if (operations != null) { + return new ArrayList(operations); + } + else { + return new ArrayList(); + } } @Override