Skip to content

JmsException.getMessage throws NPE if a cause doesn't have a message [SPR-5332] #10005

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions