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

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


The following commit(s) were added to refs/heads/main by this push:
     new b7850a48caf SOLR-18473: Fix CrossDC Consumer NPE on shutdown. (#4932)
b7850a48caf is described below

commit b7850a48cafe39bdd55ca6abae011bfc0911b9c0
Author: Andrzej BiaƂecki <[email protected]>
AuthorDate: Tue Sep 22 18:46:14 2026 +0200

    SOLR-18473: Fix CrossDC Consumer NPE on shutdown. (#4932)
---
 .../java/org/apache/solr/response/PrometheusResponseWriter.java  | 3 +++
 .../org/apache/solr/response/TestPrometheusResponseWriter.java   | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git 
a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java 
b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java
index d56a85b9bbe..f2628bb9240 100644
--- a/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/PrometheusResponseWriter.java
@@ -85,6 +85,9 @@ public class PrometheusResponseWriter implements 
QueryResponseWriter {
   }
 
   private boolean writeOpenMetricsFormat(SolrQueryRequest request) {
+    if (request == null) {
+      return false;
+    }
     String wt = request.getParams().get(CommonParams.WT);
     if (MetricUtils.OPEN_METRICS_WT.equals(wt)) {
       return true;
diff --git 
a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java 
b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
index 3c6032df129..a3848eb4c3f 100644
--- 
a/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
+++ 
b/solr/core/src/test/org/apache/solr/response/TestPrometheusResponseWriter.java
@@ -180,6 +180,15 @@ public class TestPrometheusResponseWriter extends 
SolrTestCaseJ4 {
     }
   }
 
+  @Test
+  public void testNullRequestDefaultsToPrometheusFormat() {
+    PrometheusResponseWriter writer = new PrometheusResponseWriter();
+    assertEquals(
+        "Null request should not NPE and should default to Prometheus format",
+        PrometheusResponseWriter.CONTENT_TYPE_PROMETHEUS,
+        writer.getContentType(null, null));
+  }
+
   @Test
   public void testUnsupportedMetricsFormat() throws Exception {
     var req = new MetricsRequest();

Reply via email to