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/01/08 03:45:31 UTC

[camel] branch camel-2.x updated: [ENTESB-12590] Camel netty4 requestTimeout doesn't work as expected (#3466)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new 0b20802  [ENTESB-12590] Camel netty4 requestTimeout doesn't work as expected (#3466)
0b20802 is described below

commit 0b20802e728eb7cef1d3edd1849892396662ce46
Author: JiriOndrusek <jo...@redhat.com>
AuthorDate: Wed Jan 8 04:45:15 2020 +0100

    [ENTESB-12590] Camel netty4 requestTimeout doesn't work as expected (#3466)
---
 .../component/netty4/handlers/ClientChannelHandler.java   |  6 ------
 .../camel/component/netty4/NettyRequestTimeoutTest.java   | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

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 c9a88bf..3f3dc7d 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
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.netty4.handlers;
 
-import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import org.apache.camel.AsyncCallback;
@@ -149,11 +148,6 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
             LOG.trace("Message received: {}", msg);
         }
 
-        ChannelHandler handler = ctx.pipeline().get("timeout");
-        if (handler != null) {
-            LOG.trace("Removing timeout channel as we received message");
-            ctx.pipeline().remove(handler);
-        }
 
         NettyCamelState state = getState(ctx, msg);
         Exchange exchange = state != null ? state.getExchange() : null;
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
index d9fd83d..775b8f6 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.netty4;
 
 import io.netty.handler.timeout.ReadTimeoutException;
 import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -46,6 +47,20 @@ public class NettyRequestTimeoutTest extends BaseNettyTest {
     }
 
     @Test
+    public void testKeepingTimeoutHeader() throws Exception {
+        Endpoint endpoint = this.resolveMandatoryEndpoint("netty4:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=100");
+        try {
+            String out = template.requestBody(endpoint, "Hello", String.class);
+            assertEquals("Bye World", out);
+            template.requestBody(endpoint, "Hello Camel", String.class);
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            ReadTimeoutException cause = assertIsInstanceOf(ReadTimeoutException.class, e.getCause());
+            assertNotNull(cause);
+        }
+    }
+
+    @Test
     public void testRequestTimeoutViaHeader() throws Exception {
         try {
             template.requestBodyAndHeader("netty4:tcp://localhost:{{port}}?textline=true&sync=true", "Hello Camel", NettyConstants.NETTY_REQUEST_TIMEOUT, 100, String.class);