From a134b62a96d53fb2ed98977cec801e0395afa377 Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Wed, 14 May 2014 15:46:27 +0100 Subject: [PATCH] 7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize Reviewed-by: chegar, martin, mduigou --- .../classes/java/util/concurrent/ThreadPoolExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java index 882067dfe4d..70e2ee503a6 100644 --- a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -1532,10 +1532,12 @@ public class ThreadPoolExecutor extends AbstractExecutorService { * * @param corePoolSize the new core size * @throws IllegalArgumentException if {@code corePoolSize < 0} + * or {@code corePoolSize} is greater than the {@linkplain + * #getMaximumPoolSize() maximum pool size} * @see #getCorePoolSize */ public void setCorePoolSize(int corePoolSize) { - if (corePoolSize < 0) + if (corePoolSize < 0 || maximumPoolSize < corePoolSize) throw new IllegalArgumentException(); int delta = corePoolSize - this.corePoolSize; this.corePoolSize = corePoolSize;