Package hudson.util
Class ClassLoaderSanityThreadFactory
- java.lang.Object
-
- hudson.util.ClassLoaderSanityThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class ClassLoaderSanityThreadFactory extends Object implements ThreadFactory
Explicitly sets theThread.setContextClassLoader(java.lang.ClassLoader)
for threads it creates to its own classloader. This avoids issues where threads are lazily created (ex by invokingScheduledExecutorService.schedule(Runnable, long, TimeUnit)
) in a context where they would receive a customizedThread.getContextClassLoader()
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
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderSanityThreadFactory(ThreadFactory delegate)
-
-
-
Constructor Detail
-
ClassLoaderSanityThreadFactory
public ClassLoaderSanityThreadFactory(ThreadFactory delegate)
-
-
Method Detail
-
newThread
public Thread newThread(Runnable r)
- Specified by:
newThread
in interfaceThreadFactory
-
-