[slf4j-dev] [JIRA] Updates for SLF4J-563: Reload4jMDCAdapter.setContextMap does not work correctly in 2.0

QOS.CH (JIRA) noreply-jira at qos.ch
Mon Sep 19 23:18:00 CEST 2022


SLF4J / SLF4J-563 [Open]
Reload4jMDCAdapter.setContextMap does not work correctly in 2.0

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-563

==============================
 Issue created
------------------------------

Michael Wartes created this issue on 19/Sep/22 11:02 PM
Summary:              Reload4jMDCAdapter.setContextMap does not work correctly in 2.0
Issue Type:           Bug
Affects Versions:     2.0.0
Assignee:             SLF4J developers list
Created:              19/Sep/22 11:02 PM
Priority:             Minor
Reporter:             Michael Wartes
Description:
  The Reload4jMDCAdapter has been updated in 2.0 and the setContextMap method has a small but crucial logic bug in the case where the existing MDC is null.
  
  Compare [Reload4jMDCAdapter from 1.7.36|https://github.com/qos-ch/slf4j/blob/e9ee55cca93c2bf26f14482a9bdf961c750d2a56/slf4j-reload4j/src/main/java/org/slf4j/impl/Reload4jMDCAdapter.java#L84] and the [Reload4jMDCAdapter from the current master branch|https://github.com/qos-ch/slf4j/blob/master/slf4j-reload4j/src/main/java/org/slf4j/reload4j/Reload4jMDCAdapter.java#L99].
  
  The former iterates over the context map and adds entries to the MDC like this:
  
  
  {code:java}
  org.apache.log4j.MDC.put((String) mapEntry.getKey(), mapEntry.getValue());
  {code}
  The latter also iterates over the context map but adds entries like this:
  {code:java}
  org.apache.log4j.MDC.put(mapEntry.getKey(), mapEntry);
  {code}
  This winds up setting an MDC where the keys are mapped to the MapEntry objects of the original context map instead of the values from that map.


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)



More information about the slf4j-dev mailing list