--- jsr166/src/test/tck/ThreadPoolExecutorTest.java 2015/05/15 18:21:19 1.53 +++ jsr166/src/test/tck/ThreadPoolExecutorTest.java 2015/09/04 19:35:46 1.54 @@ -1331,6 +1331,34 @@ public class ThreadPoolExecutorTest exte } /** + * Configuration changes that allow core pool size greater than + * max pool size result in IllegalArgumentException. + */ + public void testPoolSizeInvariants() { + ThreadPoolExecutor p = + new ThreadPoolExecutor(1, 1, + LONG_DELAY_MS, MILLISECONDS, + new ArrayBlockingQueue(10)); + for (int s = 1; s < 5; s++) { + p.setMaximumPoolSize(s); + p.setCorePoolSize(s); + try { + p.setMaximumPoolSize(s - 1); + shouldThrow(); + } catch (IllegalArgumentException success) {} + assertEquals(s, p.getCorePoolSize()); + assertEquals(s, p.getMaximumPoolSize()); + try { + p.setCorePoolSize(s + 1); + shouldThrow(); + } catch (IllegalArgumentException success) {} + assertEquals(s, p.getCorePoolSize()); + assertEquals(s, p.getMaximumPoolSize()); + } + joinPool(p); + } + + /** * setKeepAliveTime throws IllegalArgumentException * when given a negative value */