Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-414

MDCAdapter does not handle null map

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.7.25
    • Fix Version/s: None
    • Component/s: Implementations
    • Labels:
      None

      Description

      It turned out that method org.slf4j.impl.Log4jMDCAdapter#getCopyOfContextMap() may return null however org.slf4j.impl.Log4jMDCAdapter#setContextMap() does not handle this situation. That causes the Slf4j API consumer to eventually break with NPE in this code, depending on implementation / current logging backend provider:

      Map<String, String> mcdContextMap = MDC.getCopyOfContextMap();
      ...
      MDC.setContextMap(mcdContextMap);
      

      It is expected that MDC.setContextMap() API treats null map as empty map.

        Attachments

          Activity

            People

            • Assignee:
              slf4j-dev SLF4J developers list
              Reporter:
              dma_k Dmitry
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: