camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/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
Date Tue, 07 Feb 2017 17:45:22 GMT
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/e6d82eac
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e6d82eac
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e6d82eac

Branch: refs/heads/camel-2.17.x
Commit: e6d82eaca5513e808e65344d21a74b9c7545c135
Parents: 850cb84
Author: Thopap <Thomas.papke@icw.de>
Authored: Tue Feb 7 09:06:57 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Feb 7 18:42:14 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/e6d82eac/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 9e0cb87..cf8d9cd 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/e6d82eac/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"));
         }
 
     }


Mime
View raw message