From 9e5b0a36880c55547c6756e78b506fb79b45871c Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 17 Sep 2020 18:56:21 +0200 Subject: [PATCH] Update BoundedExecutorService.java --- .../concurrency/executor/BoundedExecutorService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java b/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java index 9fc7928..368e87f 100644 --- a/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java +++ b/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java @@ -58,6 +58,7 @@ public class BoundedExecutorService { long keepAliveTime, TimeUnit unit, @Nullable BiConsumer queueSizeStatus) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return create(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, Executors.defaultThreadFactory(), queueSizeStatus); } @@ -69,6 +70,7 @@ public class BoundedExecutorService { TimeUnit unit, ThreadFactory threadFactory, @Nullable BiConsumer queueSizeStatus) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return createCustom(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, threadFactory, Duration.ofDays(100000), queueSizeStatus, new LinkedBlockingQueue<>(MAX_BLOCKING_QUEUE_SIZE)); } @@ -81,6 +83,7 @@ public class BoundedExecutorService { ThreadFactory threadFactory, @Nullable BiConsumer queueSizeStatus, BlockingQueue queue) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return createCustom(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, threadFactory, Duration.ofDays(100000), queueSizeStatus, queue); }