You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/12/11 14:40:59 UTC
[camel] branch camel-3.7.x updated: CAMEL-15937: camel-netty -
Avoid WARN log when disconnect=true due and response received which causes
callback to be triggered twice. Thanks to Nils Kremer for reporting and
reproducer.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.7.x by this push:
new 41d9549 CAMEL-15937: camel-netty - Avoid WARN log when disconnect=true due and response received which causes callback to be triggered twice. Thanks to Nils Kremer for reporting and reproducer.
41d9549 is described below
commit 41d9549b6536cc465c02c809db328b39be29ba94
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Dec 11 15:25:35 2020 +0100
CAMEL-15937: camel-netty - Avoid WARN log when disconnect=true due and response received which causes callback to be triggered twice. Thanks to Nils Kremer for reporting and reproducer.
---
.../component/netty/handlers/ClientChannelHandler.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index dd9c6e0..ee7a43c 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -42,6 +42,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
private final NettyProducer producer;
private volatile boolean messageReceived;
private volatile boolean exceptionHandled;
+ private volatile boolean disconnecting;
public ClientChannelHandler(NettyProducer producer) {
this.producer = producer;
@@ -55,6 +56,11 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
// to keep track of open sockets
producer.getAllChannels().add(ctx.channel());
+ // reset flags
+ disconnecting = false;
+ messageReceived = false;
+ exceptionHandled = false;
+
super.channelActive(ctx);
}
@@ -113,7 +119,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.channel());
- if (exchange != null) {
+ if (exchange != null && !disconnecting) {
// this channel is maybe closing graceful and the exchange is already done
// and if so we should not trigger an exception
boolean doneUoW = exchange.getUnitOfWork() == null;
@@ -138,6 +144,9 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
}
}
+ // reset flag as the channel has been disconnected (state is now inactive)
+ disconnecting = false;
+
// make sure the event can be processed by other handlers
super.channelInactive(ctx);
}
@@ -211,6 +220,8 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
if (LOG.isTraceEnabled()) {
LOG.trace("Closing channel when complete at address: {}", producer.getConfiguration().getAddress());
}
+ // flag to know we are forcing a disconnect
+ disconnecting = true;
NettyHelper.close(ctx.channel());
}
} finally {