This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0bffa4ecc15dda97b7ee75157bbbcfb90db023dd Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Jun 12 13:52:14 2023 +0200 (chores) camel-base-engine: cleanup duplicated code --- .../impl/engine/BaseExecutorServiceManager.java | 26 ++++++---------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BaseExecutorServiceManager.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BaseExecutorServiceManager.java index 83f786db44f..ce257862a9a 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BaseExecutorServiceManager.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BaseExecutorServiceManager.java @@ -345,6 +345,12 @@ public class BaseExecutorServiceManager extends ServiceSupport implements Execut } } + doRemove(executorService, failSafe); + + return warned; + } + + private void doRemove(ExecutorService executorService, boolean failSafe) { // let lifecycle strategy be notified as well which can let it be managed in JMX as well ThreadPoolExecutor threadPool = null; if (executorService instanceof ThreadPoolExecutor) { @@ -362,8 +368,6 @@ public class BaseExecutorServiceManager extends ServiceSupport implements Execut if (!failSafe) { executorServices.remove(executorService); } - - return warned; } @Override @@ -389,23 +393,7 @@ public class BaseExecutorServiceManager extends ServiceSupport implements Execut } } - // let lifecycle strategy be notified as well which can let it be managed in JMX as well - ThreadPoolExecutor threadPool = null; - if (executorService instanceof ThreadPoolExecutor) { - threadPool = (ThreadPoolExecutor) executorService; - } else if (executorService instanceof SizedScheduledExecutorService) { - threadPool = ((SizedScheduledExecutorService) executorService).getScheduledThreadPoolExecutor(); - } - if (threadPool != null) { - for (LifecycleStrategy lifecycle : camelContext.getLifecycleStrategies()) { - lifecycle.onThreadPoolRemove(camelContext, threadPool); - } - } - - // remove reference as its shutdown (do not remove if fail-safe) - if (!failSafe) { - executorServices.remove(executorService); - } + doRemove(executorService, failSafe); return answer; }