Document using ThreadLocal#remove instead of ThreadLocal#set(null)

See gh-32874
This commit is contained in:
Seungrae 2024-05-23 02:00:47 +09:00 committed by Stéphane Nicoll
parent 3b53ee7038
commit 61ef5a8930
1 changed files with 1 additions and 1 deletions

View File

@ -222,7 +222,7 @@ incorrectly using them in multi-threaded and multi-classloader environments. You
should always consider wrapping a `ThreadLocal` in some other class and never directly use should always consider wrapping a `ThreadLocal` in some other class and never directly use
the `ThreadLocal` itself (except in the wrapper class). Also, you should the `ThreadLocal` itself (except in the wrapper class). Also, you should
always remember to correctly set and unset (where the latter simply involves a call to always remember to correctly set and unset (where the latter simply involves a call to
`ThreadLocal.set(null)`) the resource local to the thread. Unsetting should be done in `ThreadLocal.remove()`) the resource local to the thread. Unsetting should be done in
any case, since not unsetting it might result in problematic behavior. Spring's any case, since not unsetting it might result in problematic behavior. Spring's
`ThreadLocal` support does this for you and should always be considered in favor of using `ThreadLocal` support does this for you and should always be considered in favor of using
`ThreadLocal` instances without other proper handling code. `ThreadLocal` instances without other proper handling code.