Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Dec 1, 2008 · 0 comments
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) status: duplicate A duplicate of another issue

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 1, 2008

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants