You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/01/07 10:08:29 UTC

[camel] branch camel-3.0.x updated: [CAMEL-14363] Camel netty requestTimeout doesn't work as expected

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

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


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new 29e03f0  [CAMEL-14363] Camel netty requestTimeout doesn't work as expected
29e03f0 is described below

commit 29e03f0e9ae571c55eafb70f1688cc6dbbba0e00
Author: JiriOndrusek <jo...@redhat.com>
AuthorDate: Mon Jan 6 11:02:09 2020 +0100

    [CAMEL-14363] Camel netty requestTimeout doesn't work as expected
---
 .../component/netty/handlers/ClientChannelHandler.java   |  6 ------
 .../camel/component/netty/NettyRequestTimeoutTest.java   | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

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 1947e6e..08a7fb2 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
@@ -149,12 +149,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;
         if (exchange == null) {
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutTest.java
index 4ad74c2..7040e48 100644
--- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutTest.java
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.netty;
 
 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;
@@ -43,6 +44,21 @@ public class NettyRequestTimeoutTest extends BaseNettyTest {
     }
 
     @Test
+    public void testKeepingTimeoutHeader() throws Exception {
+        Endpoint endpoint = this.resolveMandatoryEndpoint("netty: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("netty:tcp://localhost:{{port}}?textline=true&sync=true", "Hello Camel", NettyConstants.NETTY_REQUEST_TIMEOUT, 100, String.class);