Repository: camel Updated Branches: refs/heads/camel-2.17.x be2097a16 -> 7bfed8285 refs/heads/camel-2.18.x 11ba337d8 -> 927d1d980 refs/heads/master c2408fc4a -> 87557bac1
CAMEL-10756 Mina2 Producer "hang" until timeout if the response message * Allow java7 compatiblity * avoid handling of I/O Exceptions which are handled by mina itself Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/862727bf Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/862727bf Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/862727bf Branch: refs/heads/master Commit: 862727bfaee2d18e14035780405ce9972a30a16a Parents: 06b69e5 Author: Thopap <thomas.pa...@icw.de> Authored: Tue Feb 7 09:06:57 2017 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Feb 7 18:32:10 2017 +0100 ---------------------------------------------------------------------- .../apache/camel/component/mina2/Mina2Producer.java | 7 ++++++- .../camel/component/mina2/Mina2CustomCodecTest.java | 15 +++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/862727bf/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java ---------------------------------------------------------------------- diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java index 7dd1795..7f6cc03 100644 --- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java +++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.mina2; +import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.charset.Charset; @@ -512,12 +513,16 @@ public class Mina2Producer extends DefaultProducer implements ServicePoolAware { this.message = null; this.messageReceived = false; this.cause = cause; - if (ioSession != null) { + if (ioSession != null && !closedByMina(cause)) { CloseFuture closeFuture = ioSession.closeNow(); closeFuture.awaitUninterruptibly(timeout, TimeUnit.MILLISECONDS); } } + private boolean closedByMina(Throwable cause) { + return cause instanceof IOException; + } + public Throwable getCause() { return this.cause; } http://git-wip-us.apache.org/repos/asf/camel/blob/862727bf/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java ---------------------------------------------------------------------- diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java index 3a86190..195455c 100644 --- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java +++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2CustomCodecTest.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.mina2; -import java.util.Optional; -import java.util.stream.Stream; - import org.apache.camel.CamelExecutionException; import org.apache.camel.ResolveEndpointFailedException; import org.apache.camel.builder.RouteBuilder; @@ -61,11 +58,13 @@ public class Mina2CustomCodecTest extends BaseMina2Test { fail("Expecting that decode of result fails"); } catch (Exception e){ assertTrue(e instanceof CamelExecutionException); - Optional<Throwable> rootCause = Stream.iterate(e, Throwable::getCause) - .filter(element -> element.getCause() == null).findFirst(); - assertTrue(rootCause.isPresent()); - assertTrue(rootCause.get() instanceof IllegalArgumentException); - assertTrue(rootCause.get().getMessage().contains("Something went wrong in decode")); + assertNotNull(e.getCause()); + Throwable rootCause = e; + while(rootCause.getCause() != null){ + rootCause = rootCause.getCause(); + } + assertTrue(rootCause instanceof IllegalArgumentException); + assertTrue(rootCause.getMessage().contains("Something went wrong in decode")); } }