Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8362123

ClassLoader Leak via Executors.newSingleThreadExecutor(...)

XMLWordPrintable

      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."

            vklang Viktor Klang
            vklang Viktor Klang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: