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 2013/09/18 11:20:47 UTC

[3/6] git commit: CAMEL-6730: Fixed requestTimeout on camel-netty.

CAMEL-6730: Fixed requestTimeout on camel-netty.


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

Branch: refs/heads/camel-2.12.x
Commit: e6326d9c800984e5e38e788dbd48fc95d1aababd
Parents: 111ba6a
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Sep 18 11:18:05 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Sep 18 11:19:34 2013 +0200

----------------------------------------------------------------------
 .../netty/handlers/ClientChannelHandler.java         | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e6326d9c/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 b55f4b7..b830c95 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
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.netty.handlers;
 
+import java.util.List;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
@@ -26,11 +28,13 @@ import org.apache.camel.component.netty.NettyHelper;
 import org.apache.camel.component.netty.NettyPayloadHelper;
 import org.apache.camel.component.netty.NettyProducer;
 import org.apache.camel.util.ExchangeHelper;
+import org.jboss.netty.channel.ChannelHandler;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.ChannelStateEvent;
 import org.jboss.netty.channel.ExceptionEvent;
 import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -120,17 +124,20 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
 
     @Override
     public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) throws Exception {
+        messageReceived = true;
+
         if (LOG.isTraceEnabled()) {
             LOG.trace("Message received: {}", messageEvent);
         }
 
         if (producer.getConfiguration().getRequestTimeout() > 0) {
-            LOG.trace("Removing timeout channel as we received message");
-            ctx.getPipeline().remove("timeout");
+            ChannelHandler handler = ctx.getPipeline().get("timeout");
+            if (handler != null) {
+                LOG.trace("Removing timeout channel as we received message");
+                ctx.getPipeline().remove(handler);
+            }
         }
 
-        messageReceived = true;
-
         Exchange exchange = getExchange(ctx);
         AsyncCallback callback = getAsyncCallback(ctx);