camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1355262 - /camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
Date Fri, 29 Jun 2012 08:24:30 GMT
Author: davsclaus
Date: Fri Jun 29 08:24:29 2012
New Revision: 1355262

URL: http://svn.apache.org/viewvc?rev=1355262&view=rev
Log:
CAMEL-5405: Ensure mina producer always disconnects if configured to do so, even for timeouts
when doing request/reply.

Modified:
    camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java

Modified: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java?rev=1355262&r1=1355261&r2=1355262&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
(original)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
Fri Jun 29 08:24:29 2012
@@ -59,7 +59,7 @@ import org.slf4j.LoggerFactory;
 /**
  * A {@link org.apache.camel.Producer} implementation for MINA
  *
- * @version 
+ * @version
  */
 public class Mina2Producer extends DefaultProducer implements ServicePoolAware {
 
@@ -106,8 +106,17 @@ public class Mina2Producer extends Defau
         return false;
     }
 
-    @SuppressWarnings("deprecation")
     public void process(Exchange exchange) throws Exception {
+        try {
+            doProcess(exchange);
+        } finally {
+            // ensure we always disconnect if configured
+            maybeDisconnectOnDone(exchange);
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    protected void doProcess(Exchange exchange) throws Exception {
         if (session == null && !lazySessionCreation) {
             throw new IllegalStateException("Not started yet!");
         }
@@ -176,6 +185,12 @@ public class Mina2Producer extends Defau
                 }
             }
         }
+    }
+
+    protected void maybeDisconnectOnDone(Exchange exchange) {
+        if (session == null) {
+            return;
+        }
 
         // should session be closed after complete?
         Boolean close;



Mime
View raw message