From ecbeb6d2eb8675832acec243a4e50fea735763e0 Mon Sep 17 00:00:00 2001 From: jbonofre Date: Tue, 19 May 2020 16:51:23 +0200 Subject: [PATCH] [AMQ-7480] Avoid NPE if original exception is null --- .../java/org/apache/activemq/TransactionContext.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java b/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java index bb5735fdc0..fbc2fdfd4f 100644 --- a/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java +++ b/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java @@ -799,12 +799,16 @@ public class TransactionContext implements XAResource { if (e.getCause() != null && e.getCause() instanceof XAException) { XAException original = (XAException)e.getCause(); XAException xae = new XAException(original.getMessage()); - xae.errorCode = original.errorCode; - if (xae.errorCode == XA_OK) { + if (original != null) { + xae.errorCode = original.errorCode; + } + if (original != null && xae != null && xae.errorCode == XA_OK) { // detail not unmarshalled see: org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.createThrowable xae.errorCode = parseFromMessageOr(original.getMessage(), XAException.XAER_RMERR); } - xae.initCause(original); + if (original != null) { + xae.initCause(original); + } return xae; }