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:
Artem Bilan
2015-09-08 22:55:52 -04:00
parent f607f83bf2
commit cb318f59ee
14 changed files with 46 additions and 27 deletions

View File

@@ -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();
}
/**

View File

@@ -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;
}

View File

@@ -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;
}