Integrated: 8302899: Executors.newSingleThreadExecutor can use Cleaner to shutdown executor
Alan Bateman
alanb at openjdk.org
Sat Feb 25 07:52:16 UTC 2023
On Mon, 20 Feb 2023 18:34:17 GMT, Alan Bateman <alanb at 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 this change, I've added a RF to DelegatedExecutorService.shutdown to be consistent with the other methods - this is a benign change and avoids needing to puzzle over why it wasn't there previously. I've replaced the existing test with a more modern test that exercises more scenarios.
This pull request has now been integrated.
Changeset: 2e78d838
Author: Alan Bateman <alanb at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2e78d838a5e55e3ef68bc8df2b40615e8bdb0389
Stats: 138 lines in 2 files changed: 53 ins; 11 del; 74 mod
8302899: Executors.newSingleThreadExecutor can use Cleaner to shutdown executor
Reviewed-by: rriggs, martin, dfuchs, bchristi
-------------
PR: https://git.openjdk.org/jdk/pull/12675
More information about the core-libs-dev
mailing list