JmsException.getMessage throws NPE if a cause doesn't have a message [SPR-5332] #10005
Labels
in: messaging
Issues in messaging modules (jms, messaging)
status: duplicate
A duplicate of another issue
Konstantin Khrapchenko opened SPR-5332 and commented
Under some circumstances a JMS Exception may have a message unassigned i.e. its getMessage() returns null.
Like in #9948 that fixed JmsUtils.buildExceptionMessage I can propose a fix like
public String getMessage() {
String message = super.getMessage();
Throwable cause = getCause();
if (cause instanceof JMSException) {
Exception linkedEx = ((JMSException) cause).getLinkedException();
if (linkedEx != null && (cause.getMessage() != null && cause.getMessage().indexOf(linkedEx.getMessage()) == -1 || cause.getMessage() == null)) {
message = message + "; nested exception is " + linkedEx;
}
}
return message;
}
Affects: 2.5.6
Issue Links:
The text was updated successfully, but these errors were encountered: