Closed
Description
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:
- JmsUtils.buildExceptionMessage throws NPE if the linked exception doesn't have a message [SPR-5275] #9948 JmsUtils.buildExceptionMessage throws NPE if the linked exception doesn't have a message ("duplicates")