fixed JmsException/JmsUtils to fully avoid NPEs in case of cause messages being null
This commit is contained in:
parent
777a104d48
commit
8669b3293c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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;
|
||||
|
|
Loading…
Reference in New Issue