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

(ch, fs) Replace anonymous Thread with InnocuousThread

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • core-libs
    • None
    • behavioral
    • minimal
    • It appears unlikely that anything might depend on the default thread pool inheriting properties from user threads
    • Java API
    • SE

      Summary

      Change the default thread pool used by asynchronous channels in java.nio.channels to be "innocuous threads", meaning they don't inherit the thread-context-class-loader or inheritable-ThreadLocals from the caller thread.

      Problem

      The asynchronous channels in java.nio.channels (AsynchronousSocketChannel, AsynchronousFileChannel, ..) allow a completion handler to be invoked when an I/O operation completes. The thread pool used to invoke completion handlers is configurable but when not specified, a default thread pool is used. At things stand, the threads in this default pool will inherit the thread-context-class-loader and any inheritable-ThreadLocals from the caller thread, usually a thread that initiates an I/O operation.

      This inheritance can lead to memory leak / retention issues, say when a caller thread has a large graph of objects reachable via its TCCL. If inherited into a thread in the default thread pool then this graph of objects will remain reachable after the original caller thread has terminated.

      Solution

      Make the change described in the Summary section above. The proposed new behavior (to not inherit) aligns the implementation with past behavior when running with a SecurityManager.

      Specification

      There are no specification changes.

            bpb Brian Burkhalter
            bpb Brian Burkhalter
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: