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/f0a65e6a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0a65e6a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0a65e6a Branch: refs/heads/camel-2.15.x Commit: f0a65e6a35a9fed4cca32787f2713d7a419b27ff Parents: 1805c6b 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:50:17 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/f0a65e6a/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 9e51053..937d2d0 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 @@ -107,7 +107,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 @@ -197,6 +197,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.