public class ThreadLocalCleanUp extends Object implements ClassLoaderPreMortemCleanUp, MustBeAfter<ClassLoaderPreMortemCleanUp>
ThreadLocals for which ThreadLocal.remove() has not been called, in case either the
ThreadLocal is a custom one (subclassed in the protected ClassLoader), or the value is loaded by (or is)
the protected ClassLoader.
This must be done after threads have been stopped, or new ThreadLocals may be added by those threads.| Modifier and Type | Field and Description |
|---|---|
protected Field |
java_lang_Thread_inheritableThreadLocals |
protected Field |
java_lang_Thread_threadLocals |
protected Field |
java_lang_ThreadLocal$ThreadLocalMap_table |
protected Field |
java_lang_ThreadLocal$ThreadLocalMap$Entry_value |
| Constructor and Description |
|---|
ThreadLocalCleanUp() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp(ClassLoaderLeakPreventor preventor)
Perform cleanup actions needed to make provided
ClassLoaderLeakPreventor.classLoader
ready for garbage collection. |
protected void |
forEachThreadLocalInThread(ClassLoaderLeakPreventor preventor,
Thread thread) |
Class<? extends ClassLoaderPreMortemCleanUp>[] |
mustBeBeforeMe()
Needs to be done after
StopThreadsCleanUp, since new ThreadLocals may be added when threads are
shutting down. |
protected void |
processLeak(ClassLoaderLeakPreventor preventor,
Thread thread,
Reference<?> entry,
ThreadLocal<?> threadLocal,
Object value,
String message)
After having detected potential ThreadLocal leak, this method is called.
|
protected void |
processThreadLocalMap(ClassLoaderLeakPreventor preventor,
Thread thread,
Object threadLocalMap) |
protected Field java_lang_Thread_threadLocals
protected Field java_lang_Thread_inheritableThreadLocals
protected Field java_lang_ThreadLocal$ThreadLocalMap_table
protected Field java_lang_ThreadLocal$ThreadLocalMap$Entry_value
public Class<? extends ClassLoaderPreMortemCleanUp>[] mustBeBeforeMe()
StopThreadsCleanUp, since new ThreadLocals may be added when threads are
shutting down.mustBeBeforeMe in interface MustBeAfter<ClassLoaderPreMortemCleanUp>public void cleanUp(ClassLoaderLeakPreventor preventor)
ClassLoaderPreMortemCleanUpClassLoaderLeakPreventor.classLoader
ready for garbage collection.cleanUp in interface ClassLoaderPreMortemCleanUpprotected void forEachThreadLocalInThread(ClassLoaderLeakPreventor preventor, Thread thread)
protected void processThreadLocalMap(ClassLoaderLeakPreventor preventor, Thread thread, Object threadLocalMap) throws IllegalAccessException
IllegalAccessExceptionprotected void processLeak(ClassLoaderLeakPreventor preventor, Thread thread, Reference<?> entry, ThreadLocal<?> threadLocal, Object value, String message)
Copyright © 2019. All rights reserved.