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 95d6242 CAMEL-16782: camel-core ConcurrentModificationException with camel-ftp when service pool is evicting from pool. 95d6242 is described below commit 95d62423c0c224985965575d142a902fa37247d2 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Jul 2 17:06:34 2021 +0200 CAMEL-16782: camel-core ConcurrentModificationException with camel-ftp when service pool is evicting from pool. --- .../src/main/java/org/apache/camel/support/cache/ServicePool.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 0dc1931..e98b71c 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 @@ -294,6 +294,7 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements * thread at any given time. */ private class MultiplePool implements Pool<S> { + private final Object lock = new Object(); private final Endpoint endpoint; private final BlockingQueue<S> queue; private final List<S> evicts; @@ -313,7 +314,7 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements private void cleanupEvicts() { if (!evicts.isEmpty()) { - synchronized (this) { + synchronized (lock) { if (!evicts.isEmpty()) { for (S evict : evicts) { doStop(evict); @@ -365,7 +366,9 @@ abstract class ServicePool<S extends Service> extends ServiceSupport implements @Override public void evict(S s) { // to be evicted - evicts.add(s); + synchronized (lock) { + evicts.add(s); + } } @Override