CAMEL-9527: Netty client - When channel is inactive we should not log stacktrace if the message was received and processed
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9abbd22a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9abbd22a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9abbd22a Branch: refs/heads/camel-2.16.x Commit: 9abbd22a9e9b61d5148fc936e4525a64b4ee30ca Parents: 335e7a8 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Jan 24 12:15:59 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Jan 24 12:49:42 2016 +0100 ---------------------------------------------------------------------- .../component/netty4/handlers/ClientChannelHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9abbd22a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java index 160adf4..dbb7b60 100644 --- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java +++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java @@ -112,7 +112,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> { producer.getAllChannels().remove(ctx.channel()); NettyConfiguration configuration = producer.getConfiguration(); - if (configuration.isSync() && !exceptionHandled) { + if (configuration.isSync() && !messageReceived && !exceptionHandled) { // To avoid call the callback.done twice exceptionHandled = true; // session was closed but no message received. This could be because the remote server had an internal error @@ -201,6 +201,13 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> { } } + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + // reset flag after we have read the complete + messageReceived = false; + super.channelReadComplete(ctx); + } + /** * Gets the Camel {@link Message} to use as the message to be set on the current {@link Exchange} when * we have received a reply message.