Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing all keys from ThreadContextMap does not clear the ThreadLocal #2523

Open
ppkarwasz opened this issue Apr 25, 2024 · 0 comments
Open

Comments

@ppkarwasz
Copy link
Contributor

The implementations of ThreadContextMap#remove and CleanableThreadContextMap#removeAll in the DefaultThreadContextMap and CopyOnWriteSortedArrayThreadContextMap implementations do not clear the underlying ThreadLocal, after all keys have been removed from the context map.

This issue prevents CopyOnWriteSortedArrayThreadContextMap to be safely used in a web application, if code like this is used:

ThreadContext.put("key", "value");
try {
    ...
} finally {
    ThreadContext.remove("key");
}

Remark: this issue does not affect the GarbageFreeSortedArrayThreadContextMap implementation, since leaving a non-null value of ThreadContext is part of its garbage-free design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants