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

MDCAdapter does not handle null map

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0.0-alpha2
    • 1.7.25
    • Implementations
    • 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

            ceki Ceki Gülcü
            dma_k Dmitry
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: