RFR JDK-7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize

Martin Buchholz martinrb at google.com
Wed May 14 19:23:50 UTC 2014


Thanks, Pavel.

These tests do belong in the tck tests, since they are testing spec, but
only in the jdk9-specific versions.  I'll see what I can do to integrate
them.


On Wed, May 14, 2014 at 12:15 PM, Pavel Rappo <pavel.rappo at oracle.com>wrote:

> Hi Mike,
>
> Unfortunately I don't know. I suppose it is better to rely on our own jdk
> tests. The only thing I did was sent Doug 2 patches for the tck tests. But
> as far as I can see he hasn't applied them yet. And I don't even know if he
> is going to. Here they are:
>
> --- src/test/tck/ThreadPoolExecutorSubclassTest.java    (revision 1.32)
> +++ src/test/tck/ThreadPoolExecutorSubclassTest.java    (revision )
> @@ -1180,6 +1180,23 @@
>      }
>
>      /**
> +     * setCorePoolSize(int) throws IllegalArgumentException
> +     * if given a value greater the maximum pool size
> +     */
> +    public void testCorePoolSizeIllegalArgumentException2() {
> +        ThreadPoolExecutor p =
> +                new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new
> ArrayBlockingQueue<Runnable>(10));
> +        try {
> +            p.setCorePoolSize(3);
> +            shouldThrow();
> +        } catch (IllegalArgumentException success) {
> +        } finally {
> +            try { p.shutdown(); } catch (SecurityException ok) { return; }
> +        }
> +        joinPool(p);
> +    }
> +
> +    /**
>       * setMaximumPoolSize(int) throws IllegalArgumentException
>       * if given a value less the core pool size
>       */
>
> --- src/test/tck/ThreadPoolExecutorTest.java    (revision 1.49)
> +++ src/test/tck/ThreadPoolExecutorTest.java    (revision )
> @@ -1302,6 +1302,25 @@
>      }
>
>      /**
> +     * setCorePoolSize(int) throws IllegalArgumentException if
> +     * given a value greater the maximum pool size
> +     */
> +    public void testCorePoolSizeIllegalArgumentException2() {
> +        ThreadPoolExecutor p =
> +                new ThreadPoolExecutor(1, 2,
> +                        LONG_DELAY_MS, MILLISECONDS,
> +                        new ArrayBlockingQueue<Runnable>(10));
> +        try {
> +            p.setCorePoolSize(3);
> +            shouldThrow();
> +        } catch (IllegalArgumentException success) {
> +        } finally {
> +            try { p.shutdown(); } catch (SecurityException ok) { return; }
> +        }
> +        joinPool(p);
> +    }
> +
> +    /**
>       * setMaximumPoolSize(int) throws IllegalArgumentException if
>       * given a value less the core pool size
>       */
>
>
> -Pavel
>
> On 14 May 2014, at 18:03, Mike Duigou <mike.duigou at oracle.com> wrote:
>
> > Hi Pavel;
> >
> > The change and test looks good. Will the test be upstreamed or will Doug
> be adding a similar test in his upstream?
> >
> > Mike
> >
> > On May 14 2014, at 08:29 , Pavel Rappo <pavel.rappo at oracle.com> wrote:
> >
> >> Hi everyone,
> >>
> >> could you please review my change for JDK-7153400?
> >>
> >> http://cr.openjdk.java.net/~chegar/7153400/00/webrev/
> >> http://ccc.us.oracle.com/7153400
> >>
> >> It's a long expected fix for a minor issue in the ThreadPoolExecutor.
> This has been agreed with Doug Lea. The exact same change (except for the
> test) is already in jsr166 repo:
> http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/ThreadPoolExecutor.java?r1=1.151&r2=1.152
> >>
> >> Thanks
> >> -Pavel
> >
>
>



More information about the core-libs-dev mailing list