On Thu, 23 Feb 2023 08:31:36 GMT, Alan Bateman <[email protected]> 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 with a new target base due to a
> merge or a rebase. The incremental webrev excludes the unrelated changes
> brought in by the merge/rebase. The pull request contains seven additional
> commits since the last revision:
>
> - Merge
> - Improve SM scenario
> - Keep reference to Cleanable
> - Merge
> - Fix typo in comment, remove blank line
> - Replace older test
> - Initial commit
src/java.base/share/classes/java/util/concurrent/Executors.java line 832:
> 830: private static class AutoShutdownDelegatedExecutorService
> 831: extends DelegatedExecutorService {
> 832: private final Cleanable cleaner;
"cleaner" is a Cleanable, not a Cleaner. We should consistently use (as we do
elsewhere in openjdk)
private final Cleanable cleanable;
and fix the others to be consistent:
./sun/nio/ch/DatagramChannelImpl.java:115: private final Cleanable cleaner;
./sun/nio/ch/NioSocketImpl.java:106: private Cleanable cleaner;
./java/util/concurrent/Executors.java:832: private final Cleanable
cleaner;
(BTW: I find Cleaners much harder to use than old finalize, and it looks like
I'm not the only one!)
-------------
PR: https://git.openjdk.org/jdk/pull/12675