This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.21.x by this push:
new 8cb884331ab CAMEL-19498: camel-core - Pool for non-singleton polling
consumer should be limite to capacity size, to avoid growing unlimited and leak
memory. (#11013)
8cb884331ab is described below
commit 8cb884331ab5ba0bb286f2c1b7529c8651519a39
Author: Claus Ibsen <[email protected]>
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 fe0b6fe6cf9..28ffe583fc1 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
@@ -79,7 +79,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.
*/
@@ -88,6 +88,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);
@@ -168,15 +172,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