Hi Chris,

I've opened the following JBS issue based on your email:

https://bugs.openjdk.org/browse/JDK-8362123

If you intend to open a PR against the issue, please make sure that the OCA 
status is in order and that there's a regression test associated with the 
proposed fix.

Cheers,
√


Viktor Klang
Software Architect, Java Platform Group
Oracle
________________________________
From: core-libs-dev <core-libs-dev-r...@openjdk.org> on behalf of Chris Dennis 
<chris.w.den...@gmail.com>
Sent: Friday, 11 July 2025 16:42
To: core-libs-dev <core-libs-...@openjdk.java.net>
Subject: ClassLoader Leak via Executors.newSingleThreadExecutor(...)

Hi All,

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.

Thanks,

Chris

P.S. I believe I'm likely covered wrt OCA via my employer IBM.

Reply via email to