You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by jp...@apache.org on 2019/09/25 12:59:44 UTC
[camel] branch master updated: CAMEL-14000 - remove Endpoint from
Map when corresponding Pool is empty
This is an automated email from the ASF dual-hosted git repository.
jpoth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new aa12e71 CAMEL-14000 - remove Endpoint from Map when corresponding Pool is empty
new 240e821 Merge pull request #3186 from johnpoth/CAMEL-14000
aa12e71 is described below
commit aa12e71935b7ee1e3d6ac444d10a18b10c730abc
Author: John Poth <po...@gmail.com>
AuthorDate: Mon Sep 23 12:05:30 2019 +0200
CAMEL-14000 - remove Endpoint from Map when corresponding Pool is empty
---
.../java/org/apache/camel/impl/engine/ServicePool.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ServicePool.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ServicePool.java
index 40f0502..cf38275 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ServicePool.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ServicePool.java
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
* A service pool is like a connection pool but can pool any kind of objects.
* <p/>
* Notice the capacity is <b>per key</b> which means that each key can contain at most
- * (the capacity) services. The pool can contain an unbounded number of keys.
+ * (the capacity) services. The pool will contain at most (the capacity) number of keys.
* <p/>
* By default the capacity is set to 100.
*/
@@ -56,7 +56,8 @@ public class ServicePool<S extends Service> extends ServiceSupport implements No
void release(S s);
int size();
void stop();
- void evict(S s);
+ // returns true if the pool is empty
+ boolean evict(S s);
}
static class Key<S> {
@@ -85,7 +86,9 @@ public class ServicePool<S extends Service> extends ServiceSupport implements No
Endpoint e = getEndpoint.apply(s);
Pool<S> p = pool.get(e);
if (p != null) {
- p.evict(s);
+ if (p.evict(s)) {
+ pool.remove(e);
+ }
}
}
@@ -249,13 +252,14 @@ public class ServicePool<S extends Service> extends ServiceSupport implements No
}
@Override
- public void evict(S s) {
+ public boolean evict(S s) {
synchronized (this) {
if (this.s == s) {
this.s = null;
}
}
doStop(s);
+ return true;
}
void doStop(S s) {
@@ -309,9 +313,10 @@ public class ServicePool<S extends Service> extends ServiceSupport implements No
}
@Override
- public void evict(S s) {
+ public boolean evict(S s) {
queue.remove(s);
ServicePool.stop(s);
+ return queue.isEmpty();
}
}