Updated Branches: refs/heads/camel-2.12.x cd351f0d7 -> 6e3c66a81
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/6e3c66a8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6e3c66a8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6e3c66a8 Branch: refs/heads/camel-2.12.x Commit: 6e3c66a81610b575e94344bb0f99cd0fd7f8e80f Parents: cd351f0 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:17:30 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/6e3c66a8/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 {