From d09dfd7c45f453b51d94093349c6562ee1838ef0 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Sun, 17 Oct 2010 12:30:05 -0400 Subject: [PATCH] INT-1529 NPE in inbound gateway when reply is null --- .../integration/ip/tcp/TcpInboundGateway.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java index 8561c978d0..fcf7c1a57e 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpInboundGateway.java @@ -46,10 +46,16 @@ public class TcpInboundGateway extends MessagingGatewaySupport implements TcpLis public boolean onMessage(Message message) { Message reply = this.sendAndReceiveMessage(message); + if (reply == null) { + if (logger.isDebugEnabled()) { + logger.debug("null reply received for " + message + " nothing to send"); + } + return false; + } String connectionId = (String) message.getHeaders().get(IpHeaders.CONNECTION_ID); TcpConnection connection = connections.get(connectionId); if (connection == null) { - logger.error("Connection " + connectionId + " not found"); + logger.error("Connection " + connectionId + " not found when processing reply for " + message); return false; } try {