Skip navigation links
org.apache.myfaces.trinidad.util
Class ThreadLocalUtils
java.lang.Object
org.apache.myfaces.trinidad.util.ThreadLocalUtils
-
public final class ThreadLocalUtils
- extends Object
Utility functions related to ThreadLocals. This class provides utilities for managing the lifecycles of ThreadLocals. In particular, many application servers do not clean up the ThreadLocals added to the request thread before returning the request thread to its thread pool. This may have several severe side-effects, including
- Leakage of objects referenced by the thread local
- Possible security holes if the ThreadLocals contents are reused on a request for a different user.
- Leakage of the entire class loader in live patching scenarios
- ClassCastExceptions in live patching scenarios
To avoid these problems, this class provides utilities for creating and registering ThreadLocals that will be removed from the thread automatically at the end of the current request.
- See Also:
newRequestThreadLocal(), registerRequestThreadLocal(java.lang.ThreadLocal<T>)
| Method Summary |
static
|
newRequestThreadLocal()
Creates and returns a new ThreadLocal that will be automatically removed from the each request thread when the request finishes. |
static
|
registerRequestThreadLocal(ThreadLocal<T> threadLocal)
Registers and returns the ThreadLocal to be automatically removed from the each request thread when the request finishes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
newRequestThreadLocal
public static <T> ThreadLocal<T> newRequestThreadLocal()
- Creates and returns a new ThreadLocal that will be automatically removed from the each request thread when the request finishes.
-
- Returns:
- The ThreadLocal
- See Also:
registerRequestThreadLocal(java.lang.ThreadLocal<T>)
registerRequestThreadLocal
public static <T> ThreadLocal<T> registerRequestThreadLocal(ThreadLocal<T> threadLocal)
- Registers and returns the ThreadLocal to be automatically removed from the each request thread when the request finishes.
-
- Parameters:
threadLocal - ThreadLocal to register for automatic removal
- Returns:
- The reigistered ThreadLocal
- See Also:
newRequestThreadLocal()
Skip navigation links
Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.