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 2023/08/07 07:13:45 UTC
[camel] branch main updated: CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory. (#11013)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 056aef2b062 CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory. (#11013)
056aef2b062 is described below
commit 056aef2b062ae4e1d373b8a73a4b6c8e15d9571b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 7 09:13:36 2023 +0200
CAMEL-19498: camel-core - Pool for non-singleton polling consumer should be limite to capacity size, to avoid growing unlimited and leak memory. (#11013)
---
.../java/org/apache/camel/support/cache/ServicePool.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java b/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
index 7164a021bcb..cc4afecca11 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/cache/ServicePool.java
@@ -85,7 +85,7 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
/**
* This callback is invoked by LRUCache from a separate background cleanup thread. Therefore we mark the entries to
* be evicted from this thread only, and then let SinglePool and MultiPool handle the evictions (stop the
- * producer/consumer safely) when they are acquiring/releases producers/consumers. If we sop the producer/consumer
+ * producer/consumer safely) when they are acquiring/releases producers/consumers. If we stop the producer/consumer
* from the LRUCache background thread we can have a race condition with a pooled producer may have been acquired at
* the same time its being evicted.
*/
@@ -94,6 +94,10 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
Pool<S> p = pool.get(e);
if (p != null) {
p.evict(s);
+ if (capacity > 0 && pool.size() > capacity) {
+ // the pool is growing too large, so we need to stop (stop will remove itself from pool)
+ p.stop();
+ }
} else {
// service no longer in a pool (such as being released twice, or can happen during shutdown of Camel etc)
ServicePool.stop(s);
@@ -192,15 +196,6 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements
pool.values().forEach(Pool::cleanUp);
}
- @Override
- protected void doBuild() throws Exception {
- // eager load classes
- SinglePool dummy = new SinglePool();
- LOG.trace("Loaded {}", dummy.getClass().getName());
- MultiplePool dummy2 = new MultiplePool();
- LOG.trace("Loaded {}", dummy2.getClass().getName());
- }
-
@Override
protected void doStart() throws Exception {
// noop