Package hudson.util

Class ClassLoaderSanityThreadFactory

  • All Implemented Interfaces:
    ThreadFactory

    public class ClassLoaderSanityThreadFactory
    extends Object
    implements ThreadFactory
    Explicitly sets the Thread#contextClassLoader for threads it creates to its own classloader. This avoids issues where threads are lazily created (ex by invoking ScheduledExecutorService.schedule(Runnable, long, TimeUnit)) in a context where they would receive a customized Thread#contextClassLoader that was never meant to be used. Commonly this is a problem for Groovy use, where this may result in memory leaks.
    Since:
    2.105
    See Also:
    JENKINS-49206