Skip to content

JmsUtils.buildExceptionMessage throws NPE if the linked exception doesn't have a message [SPR-5275] #9948

Closed
@spring-projects-issues

Description

@spring-projects-issues

Anders Wallgren opened SPR-5275 and commented

This method throws an exception if the linked exception's message is null. I've patched it locally as follow:

/**
 * Build a descriptive exception message for the given JMSException,
 * incorporating a linked exception's message if appropriate.
 * @param ex the JMSException to build a message for
 * @return the descriptive message String
 * @see javax.jms.JMSException#getLinkedException()
 */
public static String buildExceptionMessage(JMSException ex) {
	String message = ex.getMessage();
	Exception linkedEx = ex.getLinkedException();
	if (linkedEx != null && (linkedEx.getMessage() == null || message.indexOf(linkedEx.getMessage()) == -1)) {
		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)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions