Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16343

Handle MDC snapshot being null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 9.1, main (10.0)
    • None
    • None

    Description

      Using slf4j 2 with the jdk14 adapter, SLF4J uses the NOPMDCAdapter: https://www.slf4j.org/api/org/slf4j/helpers/NOPMDCAdapter.html. This always returns null from MDC.getCopyOfContextMap().

      In MDCSnapshot.java, there is an assumption that the context map is never null. The SOLRDispatchFilter uses MDCSnapshot.

      This results in the following traceback in our project using Solr 8.11.1 up:

      java.lang.NullPointerException
      at org.apache.solr.logging.MDCSnapshot.close(MDCSnapshot.java:53)
      at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:185)
      at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
      at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
      at com.sjsoft.jetty.AdminPasswordOrCertAuthFilter.doFilter(AdminPasswordOrCertAuthFilter.java:52)
      at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
      at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
      at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
      at org.eclipse.jetty.server.Server.handle(Server.java:516)
      at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
      at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
      at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
      at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555)
      at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410)
      at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
      at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
      at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:137)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
      at java.base/java.lang.Thread.run(Unknown Source)
      

       

      Changing MDCSnapshot to handle the possibility of a null snapshot fixes the issue.

      Attachments

        Issue Links

          Activity

            People

              krisden Kevin Risden
              dee42 Dee Moore
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m