7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize
authorchegar
Wed, 14 May 2014 15:46:27 +0100
changeset 24376 ad2f268e4a25
parent 24375 b24c12a4c734
child 24377 2e754d3dbdf2
7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize Reviewed-by: chegar, martin, mduigou Contributed-by: Pavel Rappo <pavel.rappo@oracle.com>
jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java
--- a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Thu May 15 18:18:19 2014 +0400
+++ b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Wed May 14 15:46:27 2014 +0100
@@ -1532,10 +1532,12 @@
      *
      * @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;