INT-3821: Description for MessagingException ctor
JIRA: https://jira.spring.io/browse/INT-3821 The `MessagingException` provides an empty String for its `NestedRuntimeException` for those ctors which are without `description` argument. The `NestedRuntimeException` uses `NestedExceptionUtils.buildMessage` for `getMessage()` implementation and the algorithm there is based on the `message != null` condition to build the first part of the nested cascade. In the case of empty String we end up with useless ";" part in the StackTrace logs. Fix Framework classes to use the `MessagingException` ctor with particular description.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -27,6 +27,11 @@ import org.springframework.messaging.MessageHandlingException;
|
||||
@SuppressWarnings("serial")
|
||||
public class MessageRejectedException extends MessageHandlingException {
|
||||
|
||||
/**
|
||||
* @param failedMessage the failed {@link Message}
|
||||
* @deprecated since 4.2 in favor of {@link MessageRejectedException(Message, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MessageRejectedException(Message<?> failedMessage) {
|
||||
super(failedMessage);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class FixedSubscriberChannel implements SubscribableChannel, BeanNa
|
||||
catch (RuntimeException e) {
|
||||
if (e instanceof MessagingException &&
|
||||
((MessagingException) e).getFailedMessage() == null) {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to handle Message", e);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CodecMessageConverter extends IntegrationObjectSupport implements M
|
||||
return this.codec.encode(message);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to encode Message", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -130,7 +130,7 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
|
||||
"Dispatcher failed to deliver Message.", e);
|
||||
if (e instanceof MessagingException &&
|
||||
((MessagingException) e).getFailedMessage() == null) {
|
||||
runtimeException = new MessagingException(message, e);
|
||||
runtimeException = new MessagingException(message, "Dispatcher failed to deliver Message", e);
|
||||
}
|
||||
return runtimeException;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFa
|
||||
catch (RuntimeException e) {
|
||||
if (!this.ignoreFailures) {
|
||||
if (e instanceof MessagingException && ((MessagingException) e).getFailedMessage() == null) {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to handle Message", e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -165,7 +165,7 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
|
||||
throw (MessagingException) e;
|
||||
}
|
||||
else {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to send Message", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -72,7 +72,8 @@ public class ErrorMessageSendingRecoverer implements RecoveryCallback<Object>, B
|
||||
"RetryContext: " + context.toString());
|
||||
}
|
||||
else if (!(lastThrowable instanceof MessagingException)) {
|
||||
lastThrowable = new MessagingException((Message<?>) context.getAttribute("message"), lastThrowable);
|
||||
lastThrowable = new MessagingException((Message<?>) context.getAttribute("message"),
|
||||
lastThrowable.getMessage(), lastThrowable);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
String supplement = ":failedMessage:" + ((MessagingException) lastThrowable).getFailedMessage();
|
||||
@@ -89,5 +90,7 @@ public class ErrorMessageSendingRecoverer implements RecoveryCallback<Object>, B
|
||||
public RetryExceptionNotAvailableException(Message<?> message, String description) {
|
||||
super(message, description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -49,10 +49,12 @@ public class RequestHandlerRetryAdvice extends AbstractRequestHandlerAdvice
|
||||
// Stateless unless a state generator is provided
|
||||
private volatile RetryStateGenerator retryStateGenerator =
|
||||
new RetryStateGenerator() {
|
||||
|
||||
@Override
|
||||
public RetryState determineRetryState(Message<?> message) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void setRetryTemplate(RetryTemplate retryTemplate) {
|
||||
@@ -76,28 +78,30 @@ public class RequestHandlerRetryAdvice extends AbstractRequestHandlerAdvice
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInvoke(final ExecutionCallback callback, Object target, final Message<?> message) throws Exception {
|
||||
protected Object doInvoke(final ExecutionCallback callback, Object target, final Message<?> message)
|
||||
throws Exception {
|
||||
RetryState retryState = null;
|
||||
retryState = this.retryStateGenerator.determineRetryState(message);
|
||||
messageHolder.set(message);
|
||||
|
||||
try {
|
||||
return retryTemplate.execute(new RetryCallback<Object, Exception>() {
|
||||
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
return callback.cloneAndExecute();
|
||||
}
|
||||
|
||||
}, this.recoveryCallback, retryState);
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
if (e.getFailedMessage() == null) {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to invoke handler", e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MessagingException(message, "Failed to invoke handler",
|
||||
unwrapExceptionIfNecessary(e));
|
||||
throw new MessagingException(message, "Failed to invoke handler", unwrapExceptionIfNecessary(e));
|
||||
}
|
||||
finally {
|
||||
messageHolder.remove();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -21,8 +21,9 @@ import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* Base Exception type for Message transformation errors.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MessageTransformationException extends MessagingException {
|
||||
@@ -35,8 +36,14 @@ public class MessageTransformationException extends MessagingException {
|
||||
super(message, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message the failed {@link Message}
|
||||
* @param cause the cause {@link Throwable}
|
||||
* @deprecated since 4.2 in favor of {@link MessageTransformationException(Message, String, Throwable)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public MessageTransformationException(Message<?> message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this(message, cause.getMessage(), cause);
|
||||
}
|
||||
|
||||
public MessageTransformationException(String description, Throwable cause) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -92,7 +92,7 @@ public class MessageTransformingHandler extends AbstractReplyProducingMessageHan
|
||||
if (e instanceof MessageTransformationException) {
|
||||
throw (MessageTransformationException) e;
|
||||
}
|
||||
throw new MessageTransformationException(message, e);
|
||||
throw new MessageTransformationException(message, "Failed to transform Message", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ import org.springframework.util.Assert;
|
||||
* is not used, but multiple concurrent connections can be used if the connection factory uses
|
||||
* single-use connections. For true asynchronous bi-directional communication, a pair of
|
||||
* inbound / outbound channel adapters should be used.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public class TcpInboundGateway extends MessagingGatewaySupport implements
|
||||
TcpListener, TcpSender, ClientModeCapable, OrderlyShutdownCapable {
|
||||
@@ -148,7 +148,8 @@ public class TcpInboundGateway extends MessagingGatewaySupport implements
|
||||
ApplicationEventPublisher applicationEventPublisher = cf.getApplicationEventPublisher();
|
||||
if (applicationEventPublisher != null) {
|
||||
applicationEventPublisher.publishEvent(
|
||||
new TcpConnectionFailedCorrelationEvent(this, connectionId, new MessagingException(message)));
|
||||
new TcpConnectionFailedCorrelationEvent(this, connectionId,
|
||||
new MessagingException(message, "Connection not found to process reply.")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +157,7 @@ public class TcpInboundGateway extends MessagingGatewaySupport implements
|
||||
* @return true if the associated connection factory is listening.
|
||||
*/
|
||||
public boolean isListening() {
|
||||
return this.serverConnectionFactory == null ? false
|
||||
: this.serverConnectionFactory.isListening();
|
||||
return this.serverConnectionFactory != null && this.serverConnectionFactory.isListening();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ public class TcpNetConnection extends TcpConnectionSupport implements Scheduling
|
||||
this.socketOutputStream.flush();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.publishConnectionExceptionEvent(new MessagingException(message, e));
|
||||
this.publishConnectionExceptionEvent(new MessagingException(message, "Failed TCP serialization", e));
|
||||
this.closeConnection(true);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
this.bufferedOutputStream.flush();
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.publishConnectionExceptionEvent(new MessagingException(message, e));
|
||||
this.publishConnectionExceptionEvent(new MessagingException(message, "Failed TCP serialization", e));
|
||||
this.closeConnection(true);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class SyslogReceivingChannelAdapterSupport extends MessageProduc
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MessagingException(message, e);
|
||||
throw new MessagingException(message, "Failed to send Message", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user