Updated Branches:
  refs/heads/master 64d49457b -> 07437065b

CAMEL-6948: ProducerCache should not only stop non-singelton Producers but also 
shutdown them afterwards as well if the given Producer is a ShutdownableService.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/07437065
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/07437065
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/07437065

Branch: refs/heads/master
Commit: 07437065b5de48a68b86735a095c34494c2a0bd4
Parents: 64d4945
Author: Babak Vahdat <bvah...@apache.org>
Authored: Sat Nov 9 16:14:52 2013 +0100
Committer: Babak Vahdat <bvah...@apache.org>
Committed: Sat Nov 9 16:14:52 2013 +0100

----------------------------------------------------------------------
 .../org/apache/camel/impl/ProducerCache.java    | 22 +++++++-------------
 1 file changed, 8 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/07437065/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java 
b/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
index b35eca5..4b2a172 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
@@ -30,7 +30,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.ProducerCallback;
 import org.apache.camel.ServicePoolAware;
-import org.apache.camel.ShutdownableService;
 import org.apache.camel.processor.UnitOfWorkProducer;
 import org.apache.camel.spi.ServicePool;
 import org.apache.camel.support.ServiceSupport;
@@ -136,13 +135,8 @@ public class ProducerCache extends ServiceSupport {
             // release back to the pool
             pool.release(endpoint, producer);
         } else if (!producer.isSingleton()) {
-            // stop non singleton producers as we should not leak resources
-            producer.stop();
-
-            // shutdown as well in case the producer is shutdownable
-            if (producer instanceof ShutdownableService) {
-                ShutdownableService.class.cast(producer).shutdown();
-            }
+            // stop and shutdown non-singleton producers as we should not leak 
resources
+            ServiceHelper.stopAndShutdownService(producer);
         }
     }
 
@@ -260,12 +254,12 @@ public class ProducerCache extends ServiceSupport {
                 // release back to the pool
                 pool.release(endpoint, producer);
             } else if (!producer.isSingleton()) {
-                // stop non singleton producers as we should not leak resources
+                // stop and shutdown non-singleton producers as we should not 
leak resources
                 try {
-                    ServiceHelper.stopService(producer);
+                    ServiceHelper.stopAndShutdownService(producer);
                 } catch (Exception e) {
                     // ignore and continue
-                    LOG.warn("Error stopping producer: " + producer, e);
+                    LOG.warn("Error stopping/shutdown producer: " + producer, 
e);
                 }
             }
         }
@@ -324,12 +318,12 @@ public class ProducerCache extends ServiceSupport {
                             // release back to the pool
                             pool.release(endpoint, producer);
                         } else if (!producer.isSingleton()) {
-                            // stop non singleton producers as we should not 
leak resources
+                            // stop and shutdown non-singleton producers as we 
should not leak resources
                             try {
-                                ServiceHelper.stopService(producer);
+                                ServiceHelper.stopAndShutdownService(producer);
                             } catch (Exception e) {
                                 // ignore and continue
-                                LOG.warn("Error stopping producer: " + 
producer, e);
+                                LOG.warn("Error stopping/shutdown producer: " 
+ producer, e);
                             }
                         }
                     } finally {

Reply via email to