You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/09/12 15:12:14 UTC

[solr] branch branch_9x updated: SOLR-16343: Handle MDC snapshot being null

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 306f529ae5d SOLR-16343: Handle MDC snapshot being null
306f529ae5d is described below

commit 306f529ae5d210e5ddeb6f25de4c921484a69d14
Author: Dee Moore <de...@hexagon.com>
AuthorDate: Thu Aug 18 16:10:52 2022 +0200

    SOLR-16343: Handle MDC snapshot being null
    
    Closes PR #978
---
 solr/CHANGES.txt                                            | 2 ++
 solr/core/src/java/org/apache/solr/logging/MDCSnapshot.java | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3ae7048748c..8a75eaeec69 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -115,6 +115,8 @@ Bug Fixes
 
 * SOLR-16357: CaffeineCache ramBytes incorrect accounting on updates and deletes (Alex Deparvu)
 
+* SOLR-16343: Handle MDC snapshot being null (Dee Moore via Kevin Risden)
+
 Other Changes
 ---------------------
 * SOLR-16351: Upgrade Carrot2 to 4.4.3, upgrade randomizedtesting to 2.8.0. (Dawid Weiss)
diff --git a/solr/core/src/java/org/apache/solr/logging/MDCSnapshot.java b/solr/core/src/java/org/apache/solr/logging/MDCSnapshot.java
index c5a5f81ec44..83b55d8bb04 100644
--- a/solr/core/src/java/org/apache/solr/logging/MDCSnapshot.java
+++ b/solr/core/src/java/org/apache/solr/logging/MDCSnapshot.java
@@ -45,12 +45,11 @@ public final class MDCSnapshot implements Closeable {
 
   private MDCSnapshot() {
     this.snapshot = MDC.getCopyOfContextMap();
-    assert null != snapshot;
   }
 
   public void close() {
     MDC.clear();
-    if (!snapshot.isEmpty()) { // common case optimization
+    if (snapshot != null && !snapshot.isEmpty()) { // common case optimization
       MDC.setContextMap(snapshot);
     }
   }