提交 8669b329 编写于 作者: J Juergen Hoeller

fixed JmsException/JmsUtils to fully avoid NPEs in case of cause messages being null

上级 777a104d
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -84,8 +84,12 @@ public abstract class JmsException extends NestedRuntimeException {
Throwable cause = getCause();
if (cause instanceof JMSException) {
Exception linkedEx = ((JMSException) cause).getLinkedException();
if (linkedEx != null && cause.getMessage().indexOf(linkedEx.getMessage()) == -1) {
message = message + "; nested exception is " + linkedEx;
if (linkedEx != null) {
String linkedMessage = linkedEx.getMessage();
String causeMessage = cause.getMessage();
if (linkedMessage != null && (causeMessage == null || !causeMessage.contains(linkedMessage))) {
message = message + "; nested exception is " + linkedEx;
}
}
}
return message;
......
......@@ -712,7 +712,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
/**
* Handle the given exception that arose during setup of a listener.
* Called for every such exception in every concurrent listener.
* <p>The default implementation logs the exception at error level
* <p>The default implementation logs the exception at info level
* if not recovered yet, and at debug level if already recovered.
* Can be overridden in subclasses.
* @param ex the exception to handle
......
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -256,8 +256,11 @@ public abstract class JmsUtils {
if (message == null) {
message = linkedEx.toString();
}
else if (!message.contains(linkedEx.getMessage())) {
message = message + "; nested exception is " + linkedEx;
else {
String linkedMessage = linkedEx.getMessage();
if (linkedMessage != null && !message.contains(linkedMessage)) {
message = message + "; nested exception is " + linkedEx;
}
}
}
return message;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册