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

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


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 917e38447b9 SOLR-17136: Fix SystemInfoResponse when Solr runs in 
standalone mode. (#3989)
917e38447b9 is described below

commit 917e38447b9555ba9bc53d8d8295e78dd6f5b5c1
Author: Pierre Salagnac <[email protected]>
AuthorDate: Mon Dec 29 15:17:29 2025 +0100

    SOLR-17136: Fix SystemInfoResponse when Solr runs in standalone mode. 
(#3989)
    
    This is a follow-up of #3955 to fix parsing of result from 
/admin/info/system when Solr run in non-cloud mode.
    
    (cherry picked from commit ac3d79d18ed660c25aaf0f7024beb12703052dc8)
---
 .../SOLR-17136-replace-GenericSolrRequest.yml      |  1 +
 .../client/solrj/response/SystemInfoResponse.java  | 34 ++++++++++++++--------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/changelog/unreleased/SOLR-17136-replace-GenericSolrRequest.yml 
b/changelog/unreleased/SOLR-17136-replace-GenericSolrRequest.yml
index 4d20d1a613f..0644109548d 100644
--- a/changelog/unreleased/SOLR-17136-replace-GenericSolrRequest.yml
+++ b/changelog/unreleased/SOLR-17136-replace-GenericSolrRequest.yml
@@ -2,6 +2,7 @@ title: Introduce new SolrJ SolrRequest classes for metrics and 
"system info" req
 type: added
 authors:
 - name: Isabelle Giguère
+- name: Pierre Salagnac
 links:
 - name: SOLR-17136
   url: https://issues.apache.org/jira/browse/SOLR-17136
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SystemInfoResponse.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/response/SystemInfoResponse.java
index 8dbea63118b..a34981dc16b 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SystemInfoResponse.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/response/SystemInfoResponse.java
@@ -16,7 +16,6 @@
  */
 package org.apache.solr.client.solrj.response;
 
-import java.lang.invoke.MethodHandles;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -25,14 +24,10 @@ import java.util.Set;
 import org.apache.solr.client.api.model.NodeSystemResponse;
 import org.apache.solr.client.solrj.request.json.JacksonContentWriter;
 import org.apache.solr.common.util.NamedList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /** This class holds the response from V1 "/admin/info/system" or V2 
"/node/system" */
 public class SystemInfoResponse extends SolrResponseBase {
 
-  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
   private static final long serialVersionUID = 1L;
 
   private final Map<String, NodeSystemResponse> nodesInfo = new HashMap<>();
@@ -44,10 +39,16 @@ public class SystemInfoResponse extends SolrResponseBase {
 
   @Override
   public void setResponse(NamedList<Object> response) {
-    if (getResponse() == null) super.setResponse(response);
+    if (getResponse() == null) {
+      super.setResponse(response);
+    } else {
+      assert response.equals(getResponse());
+      return;
+    }
+
     if (getResponse().get("node") == null) {
       // multi-nodes response, NamedList of 
"host:port_solr"->NodeSystemResponse
-      for (Entry<String, Object> node : getResponse()) {
+      for (Entry<String, Object> node : response) {
         if (node.getKey().endsWith("_solr")) {
           nodesInfo.put(
               node.getKey(),
@@ -55,10 +56,19 @@ public class SystemInfoResponse extends SolrResponseBase {
                   node.getValue(), NodeSystemResponse.class));
         }
       }
+
+      // If no node was found, that's very likely Solr runs in standalone mode.
+      // Add a single node info instance with null key (no node name is 
available).
+      if (nodesInfo.isEmpty()) {
+        nodesInfo.put(
+            null,
+            JacksonContentWriter.DEFAULT_MAPPER.convertValue(response, 
NodeSystemResponse.class));
+      }
+
     } else {
       // single-node response
       nodesInfo.put(
-          getResponse().get("node").toString(),
+          response.get("node").toString(),
           JacksonContentWriter.DEFAULT_MAPPER.convertValue(
               getResponse(), NodeSystemResponse.class));
     }
@@ -77,7 +87,7 @@ public class SystemInfoResponse extends SolrResponseBase {
   /** Get all modes, per node */
   public Map<String, String> getAllModes() {
     Map<String, String> allModes = new HashMap<>();
-    nodesInfo.entrySet().stream().forEach(e -> allModes.put(e.getKey(), 
e.getValue().mode));
+    nodesInfo.forEach((key, value) -> allModes.put(key, value.mode));
     return allModes;
   }
 
@@ -99,7 +109,7 @@ public class SystemInfoResponse extends SolrResponseBase {
   /** Get all ZK hosts, per node */
   public Map<String, String> getAllZkHosts() {
     Map<String, String> allModes = new HashMap<>();
-    nodesInfo.entrySet().stream().forEach(e -> allModes.put(e.getKey(), 
e.getValue().zkHost));
+    nodesInfo.forEach((key, value) -> allModes.put(key, value.zkHost));
     return allModes;
   }
 
@@ -121,7 +131,7 @@ public class SystemInfoResponse extends SolrResponseBase {
   /** Get all Solr homes, per node */
   public Map<String, String> getAllSolrHomes() {
     Map<String, String> allModes = new HashMap<>();
-    nodesInfo.entrySet().stream().forEach(e -> allModes.put(e.getKey(), 
e.getValue().solrHome));
+    nodesInfo.forEach((key, value) -> allModes.put(key, value.solrHome));
     return allModes;
   }
 
@@ -143,7 +153,7 @@ public class SystemInfoResponse extends SolrResponseBase {
   /** Get all core roots, per node */
   public Map<String, String> getAllCoreRoots() {
     Map<String, String> allModes = new HashMap<>();
-    nodesInfo.entrySet().stream().forEach(e -> allModes.put(e.getKey(), 
e.getValue().coreRoot));
+    nodesInfo.forEach((key, value) -> allModes.put(key, value.coreRoot));
     return allModes;
   }
 

Reply via email to