Skip to content

NullPointerException in JmsUtils.buildExceptionMessage() [SPR-5958] #10626

Closed
@spring-projects-issues

Description

@spring-projects-issues

Karim Qazi opened SPR-5958 and commented

I am currently using Spring 2.5.6 and we are using the DefaultMessageListenerContainer object. We were doing some integration testing and noticed that when we killed the JVM hosting our JMS Topic that our Spring DefaultMessageListenerContainer would not successfully re-establish a JMS connection after the JVM hosting the JMS Topic was restarted.

We would get a stack trace that indicated a NullPointerException from this code:

public static String buildExceptionMessage(JMSException ex) {
	String message = ex.getMessage();
	Exception linkedEx = ex.getLinkedException();
	if (linkedEx != null && message.indexOf(linkedEx.getMessage()) == -1) {  // Need to check for null on linkedEx.getMessage()
		message = message + "; nested exception is " + linkedEx;
	}
	return message;
}

You need to check for a null before calling "message.indexOf(linkedEx.getMessage())". This NPE was causing the Spring JMS internals to not automatically re-connect to the JMS Topic.


Affects: 2.5.6

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    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