Merge pull request #535 from jbonofre/AMQ-7480

[AMQ-7480] Avoid NPE if original exception is null
This commit is contained in:
Jean-Baptiste Onofré 2020-05-21 09:52:33 +02:00 committed by GitHub
commit 173426c55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}