On Tue, 21 Feb 2023 18:24:05 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> Executors.newSingleThreadExecutor returns a delegating ExecutorService that 
>> has finalizer to shutdown the underlying TPE when the wrapper is 
>> finalizable. It goes back to JDK 6 and JDK-6399443. This is the last 
>> non-empty finalizer in java.base. Removing it will likely lead to bug 
>> reports/complaints as the current behavior goes back to 2006. So the 
>> proposal is to just replace it with a Cleaner, trivially done in this case. 
>> As part of the changes, I've replaced the existing test with a more modern 
>> test that exercises more scenarios.
>
> Alan Bateman has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Fix typo in comment, remove blank line

Allow me to be your top cheerleader for upgrading jdk test infrastructure to 
junit 5.  It's enough to make me want to write some tests!

test/jdk/java/util/concurrent/Executors/AutoShutdown.java line 57:

> 55:     }
> 56: 
> 57:     private static Stream<Arguments> executorAndQueuedTaskCounts() {

I've long wondered about "cartesian products" of Streams, so off to 
stackoverflow, which (TIL) advises a chain of flatmaps except at the end where 
you just put a non-flat map.  So better style seems

    private static Stream<Arguments> executorAndQueuedTaskCounts() {
        int[] queuedTaskCounts = { 0, 1, 2 };
        return executors()
            .flatMap(s -> IntStream.of(queuedTaskCounts)
                     .mapToObj(i -> Arguments.of(s, i)));
    }

-------------

PR: https://git.openjdk.org/jdk/pull/12675

Reply via email to