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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -84,10 +84,14 @@ public abstract class JmsException extends NestedRuntimeException {
|
||||||
Throwable cause = getCause();
|
Throwable cause = getCause();
|
||||||
if (cause instanceof JMSException) {
|
if (cause instanceof JMSException) {
|
||||||
Exception linkedEx = ((JMSException) cause).getLinkedException();
|
Exception linkedEx = ((JMSException) cause).getLinkedException();
|
||||||
if (linkedEx != null && cause.getMessage().indexOf(linkedEx.getMessage()) == -1) {
|
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;
|
message = message + "; nested exception is " + linkedEx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -712,7 +712,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||||
/**
|
/**
|
||||||
* Handle the given exception that arose during setup of a listener.
|
* Handle the given exception that arose during setup of a listener.
|
||||||
* Called for every such exception in every concurrent 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.
|
* if not recovered yet, and at debug level if already recovered.
|
||||||
* Can be overridden in subclasses.
|
* Can be overridden in subclasses.
|
||||||
* @param ex the exception to handle
|
* @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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -256,10 +256,13 @@ public abstract class JmsUtils {
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message = linkedEx.toString();
|
message = linkedEx.toString();
|
||||||
}
|
}
|
||||||
else if (!message.contains(linkedEx.getMessage())) {
|
else {
|
||||||
|
String linkedMessage = linkedEx.getMessage();
|
||||||
|
if (linkedMessage != null && !message.contains(linkedMessage)) {
|
||||||
message = message + "; nested exception is " + linkedEx;
|
message = message + "; nested exception is " + linkedEx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue