diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java index 38932f6192..78cea2dff5 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNetReceivingChannelAdapter.java @@ -102,7 +102,6 @@ public class TcpNetReceivingChannelAdapter extends return; } if (messageStatus == SocketReader.MESSAGE_COMPLETE) { - processMessage(reader); if (close) { logger.debug("Closing socket because close=true"); try { @@ -110,6 +109,9 @@ public class TcpNetReceivingChannelAdapter extends } catch (IOException ioe) { logger.error("Error on close", ioe); } + } + processMessage(reader); + if (close) { break; } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java index 1e778a7eae..5cabc88d78 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpNioReceivingChannelAdapter.java @@ -177,21 +177,23 @@ public class TcpNioReceivingChannelAdapter extends return; } if (messageStatus == SocketReader.MESSAGE_COMPLETE) { + if (close) { + logger.debug("Closing channel because close=true"); + try { + key.channel().close(); + } catch (IOException ioe) { + logger.error("Error on close", ioe); + } + } Message message; message = mapper.toMessage(reader); if (message != null) { sendMessage(message); - if (close) { - logger.debug("Closing channel because close=true"); - try { - key.channel().close(); - } catch (IOException ioe) { - logger.error("Error on close", ioe); - } - } } } - } catch (Exception e) {} + } catch (Exception e) { + logger.error("Failure on read or message send", e); + } } @Override