From dea49d871fe03f5e2ecd8a5ff9b43f748f7c2614 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 17 Apr 2023 11:49:25 +0200 Subject: [PATCH] [Minor] code cleanup --- .../main/java/li/strolch/utils/ExecutorPool.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/utils/src/main/java/li/strolch/utils/ExecutorPool.java b/utils/src/main/java/li/strolch/utils/ExecutorPool.java index 49201bcc0..fe17a13a7 100644 --- a/utils/src/main/java/li/strolch/utils/ExecutorPool.java +++ b/utils/src/main/java/li/strolch/utils/ExecutorPool.java @@ -42,21 +42,12 @@ public class ExecutorPool { } public void destroy() { - - for (String poolName : this.executors.keySet()) { - logger.info("Shutting down executor pool " + poolName); - ExecutorService executor = this.executors.get(poolName); - shutdownExecutor(poolName, executor); - } - - for (String poolName : this.scheduledExecutors.keySet()) { - logger.info("Shutting down scheduled executor pool " + poolName); - ExecutorService executor = this.scheduledExecutors.get(poolName); - shutdownExecutor(poolName, executor); - } + this.executors.forEach(this::shutdownExecutor); + this.scheduledExecutors.forEach(this::shutdownExecutor); } private void shutdownExecutor(String name, ExecutorService executor) { + logger.info("Shutting down executor pool " + name); try { List tasks = executor.shutdownNow(); if (!tasks.isEmpty()) {