-
Notifications
You must be signed in to change notification settings - Fork 8
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
SLF4J MDC context clear() does not clear context #204
Comments
Thank you for pointing this out. I feel some reluctance of 'clearing' values that were not part of this context, so maybe reverting to the context as it was before is better than calling MDC.clear? I guess the question is, are pre-existing MDC values part of the captured context or not? I like to leave things the way they were. Perhaps Could you provide a unit-test that points out the bug so we can discuss this with a concrete example? |
The documentation of
When you are dealing with an executor or task execution facility provided by a third party library, there might be cases where you cannot be sure that previous tasks (not submitted by yourself) are properly cleaning up the context after themselves. In such cases calling
context-propagation/mdc-propagation/src/test/java/nl/talsmasoftware/context/mdc/MdcManagerTest.java Lines 115 to 119 in 4faad7b
I would expect that after calling Though to clarify, I am fine with |
Expected Behavior
As per documentation of
Clearable
, it should clear the context of the current thread:The correct behavior would therefore probably be to clear the MDC data using
MDC.clear()
.Actual Behavior
If the context was obtained from
MdcManager.getActiveContext()
callingclear()
does nothing.If the context was created by initializing the MDC data in the current thread (
initializeNewContext(...)
) callingclear()
only reverts to the previous state.The way in which
nl.talsmasoftware.context.ContextManagers.clearActiveContexts()
currently behaves does therefore nothing because onlyMdcManager.MdcContext
implementsClearable
and an instance of it is obtained usinggetActiveContext()
.Specifications
The text was updated successfully, but these errors were encountered: