JDK-8362123 : ClassLoader Leak via Executors.newSingleThreadExecutor(...)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 21,22,23,24,25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-07-14
  • Updated: 2025-10-30
  • Resolved: 2025-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 25 JDK 26
21.0.10Fixed 25.0.2Fixed 26 b20Fixed
Related Reports
Causes :  
Duplicate :  
Duplicate :  
Description
From an email to core-libs-dev on the 11th of July 2025 sent by Chris Dennis:

"I believe I've identified a bug in Executors.AutoShutdownDelegatedExecutorService that can trigger a classloader leak even in the presence of "correct" Executor lifecycling. AutoShutdownDelegatedExecutorService only unlinks the PhantomReference used for cleanup handling when it is shutdown via the shutdown() method. If an Executor wrapped in this way is instead shutdown using the shutdownNow() method and it references a classloader via an injected attribute: ThreadFactory, AbortPolicy, etc. then the cleanup action will reference the classloader, and the classloader will remain strongly referenced. Adding an additional override as shown in the attached patch is sufficient to fix the leak in my testing."
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/2346 Date: 2025-10-16 17:26:09 +0000
16-10-2025

[jdk21u-fix-request] Approval Request from Chris Dennis This fixes a memory leak and/or prompt garbage collection issue introduced in Java 21
16-10-2025

[jdk25u-fix-request] Approval Request from Chris Dennis This fixes a memory leak and/or prompt garbage collection issue introduced in Java 21
13-10-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk25u/pull/295 Date: 2025-10-13 16:12:40 +0000
13-10-2025

Changeset: d5a20799 Branch: master Author: Chris Dennis <chris.w.dennis@ibm.com> Committer: Alan Bateman <alanb@openjdk.org> Date: 2025-10-10 09:19:55 +0000 URL: https://git.openjdk.org/jdk/commit/d5a207994b9c374e6638e57826326f8f4593b96b
10-10-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26296 Date: 2025-07-14 15:49:04 +0000
26-09-2025