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 2017/02/07 17:45:19 UTC
[5/9] camel git commit: 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
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/387c7406
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/387c7406
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/387c7406
Branch: refs/heads/camel-2.18.x
Commit: 387c7406b5bb8167fd002376586927a30bfae401
Parents: 6adb921
Author: Thopap <Th...@icw.de>
Authored: Tue Feb 7 09:06:57 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 7 18:41:38 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/387c7406/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/387c7406/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"));
}
}