Updated Branches: refs/heads/camel-2.11.x fc9f67b1f -> c4f9a7366
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/c4f9a736 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c4f9a736 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c4f9a736 Branch: refs/heads/camel-2.11.x Commit: c4f9a73663be0a1859e7e12aed1bccb6866bd4ca Parents: fc9f67b 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:18:14 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/c4f9a736/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 591ccc4..a1f58f2 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; @@ -127,13 +126,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); } } @@ -251,12 +245,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); } } } @@ -315,12 +309,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 {