You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/01/24 08:18:31 UTC
[camel] 01/02: CAMEL-14432: Memory leak when toD is used with
cacheSize < 0 (#3510)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6500256024ed9ecbec7ecfb2e44b81f5873844e1
Author: Luigi De Masi <55...@users.noreply.github.com>
AuthorDate: Fri Jan 24 06:03:11 2020 +0100
CAMEL-14432: Memory leak when toD is used with cacheSize < 0 (#3510)
---
.../java/org/apache/camel/impl/ProducerCache.java | 36 ++++++++--------------
1 file changed, 12 insertions(+), 24 deletions(-)
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 9531494..36aa1cc 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
@@ -353,7 +353,7 @@ public class ProducerCache extends ServiceSupport {
T answer = null;
// get the producer and we do not mind if its pooled as we can handle returning it back to the pool
- Producer producer = doGetProducer(endpoint, true);
+ Producer producer = acquireProducer(endpoint);
if (producer == null) {
if (isStopped()) {
@@ -372,17 +372,11 @@ public class ProducerCache extends ServiceSupport {
exchange.setException(e);
}
} finally {
- if (producer instanceof ServicePoolAware) {
- // release back to the pool
- pool.release(endpoint, producer);
- } else if (!producer.isSingleton()) {
- // stop and shutdown non-singleton producers as we should not leak resources
- try {
- ServiceHelper.stopAndShutdownService(producer);
- } catch (Exception e) {
- // ignore and continue
- LOG.warn("Error stopping/shutting down producer: {}", producer, e);
- }
+ try {
+ releaseProducer(endpoint, producer);
+ } catch (Exception e) {
+ // ignore and continue
+ LOG.warn("Error stopping/shutting down producer: " + producer, e);
}
}
@@ -407,7 +401,7 @@ public class ProducerCache extends ServiceSupport {
Producer target;
try {
// get the producer and we do not mind if its pooled as we can handle returning it back to the pool
- target = doGetProducer(endpoint, true);
+ target = target = acquireProducer(endpoint);
if (target == null) {
if (isStopped()) {
@@ -450,17 +444,11 @@ public class ProducerCache extends ServiceSupport {
EventHelper.notifyExchangeSent(exchange.getContext(), exchange, endpoint, timeTaken);
}
- if (producer instanceof ServicePoolAware) {
- // release back to the pool
- pool.release(endpoint, producer);
- } else if (!producer.isSingleton()) {
- // stop and shutdown non-singleton producers as we should not leak resources
- try {
- ServiceHelper.stopAndShutdownService(producer);
- } catch (Exception e) {
- // ignore and continue
- LOG.warn("Error stopping/shutting down producer: {}", producer, e);
- }
+ try {
+ releaseProducer(endpoint, producer);
+ } catch (Exception e) {
+ // ignore and continue
+ LOG.warn("Error stopping/shutting down producer: " + producer, e);
}
} finally {
callback.done(doneSync);