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 2016/01/24 12:50:37 UTC

[5/9] camel git commit: CAMEL-9527: camel netty client/producer should graceful handle channel being closed/inactive without causing an exception after the exchange is done.

CAMEL-9527: camel netty client/producer should graceful handle channel being closed/inactive without causing an exception after the exchange is done.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/45bd634f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/45bd634f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/45bd634f

Branch: refs/heads/master
Commit: 45bd634f7e0db844b667480e657b103d7264d5e6
Parents: 1e5e174
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:49:09 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:49:09 2016 +0100

----------------------------------------------------------------------
 .../camel/component/netty/handlers/ClientChannelHandler.java  | 7 ++++++-
 .../camel/component/netty4/handlers/ClientChannelHandler.java | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/45bd634f/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
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 8988ad5..638d8eb 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
@@ -114,7 +114,11 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
         // to keep track of open sockets
         producer.getAllChannels().remove(ctx.getChannel());
 
-        if (producer.getConfiguration().isSync() && !messageReceived && !exceptionHandled) {
+        // 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;
+
+        if (producer.getConfiguration().isSync() && !doneUoW && !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
@@ -126,6 +130,7 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
             // signal callback
             callback.done(false);
         }
+
         // make sure the event can be processed by other handlers
         super.channelClosed(ctx, e);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/45bd634f/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 dbb7b60..ed4d695 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
@@ -111,8 +111,12 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
         // to keep track of open sockets
         producer.getAllChannels().remove(ctx.channel());
 
+        // 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;
+
         NettyConfiguration configuration = producer.getConfiguration();
-        if (configuration.isSync() && !messageReceived && !exceptionHandled) {
+        if (configuration.isSync() && !doneUoW && !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