[
https://issues.apache.org/jira/browse/SOLR-18050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18048910#comment-18048910
]
David Smiley commented on SOLR-18050:
-------------------------------------
Abuse indeed; +1 to fix
> Possible abuses of MDC context.
> -------------------------------
>
> Key: SOLR-18050
> URL: https://issues.apache.org/jira/browse/SOLR-18050
> Project: Solr
> Issue Type: Bug
> Components: logging, Server
> Affects Versions: main(11.0)
> Reporter: Gus Heck
> Priority: Minor
>
> Reading Code tonight, I discovered several places where the MDC.get() method
> is called for non-logging code. This seems like a code smell. MDC is a
> logging infrastructure, and I think it probably isn't good to use it as a
> global value passing context on which program logic depends.
>
> Suspicious usages include:
> * `this.nodeName = MDC.get(ZkStateReader.NODE_NAME_PROP);` in AuditEvent
> constructor
> * `assertEquals(value, MDC.get(key)` in
> `org.apache.solr.handler.TestHttpRequestId#setupClientAndRun`
> * `String traceId = MDCLoggingContext.getTraceId();` in
> `org.apache.solr.servlet.ServletUtils#traceHttpRequestExecution2`
> * `thisNode = MDCLoggingContext.getNodeName();` in OverSeerTaskProcessor's
> constructor.
> There seems to be one legitimate use in a test that is in fact testing MDC
> usage...
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]