Eric Pugh created SOLR-18318:
--------------------------------

             Summary: GetNodeSystemInfo (v2 `/api/node/system`) throws NPE when 
the nodes param is set
                 Key: SOLR-18318
                 URL: https://issues.apache.org/jira/browse/SOLR-18318
             Project: Solr
          Issue Type: Bug
          Components: Admin UI, v2 API
    Affects Versions: 10.0
            Reporter: Eric Pugh


Calling {{GET /api/node/system?nodes=<nodeName>}} in SolrCloud mode (requesting 
system info for one or more remote nodes via the v2 API) throws a 500 with a 
NullPointerException, instead of returning aggregated per-node data the way the 
v1 equivalent ({{{}/solr/admin/info/system?nodes=...{}}}) does.

Note: this is a SolrCloud-mode issue where node resolution succeeds and 
proxying actually starts - it is a different bug from the 
null-{{{}ZkController{}}} NPE in standalone mode tracked by SOLR-18317, though 
both live in the same 
{{{}RemoteRequestProxy{}}}/{{{}V2SolrRequestBasedProxy{}}} machinery introduced 
by SOLR-16738.
h3. Steps to reproduce

A single-node SolrCloud cluster is enough - proxying to itself still exercises 
the code path:
{code:java}
bin/solr start -c
NODE=$(curl -s 
"http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS&wt=json"; \
  | python3 -c "import json,sys; 
print(json.load(sys.stdin)['cluster']['live_nodes'][0])")

# v1 -- works fine, returns {"<node>": {...fullSystemInfo...}, 
"responseHeader": {...}}
curl -s "http://localhost:8983/solr/admin/info/system?wt=json&nodes=$NODE";

# v2 -- throws 500 NullPointerException
curl -s "http://localhost:8983/api/node/system?nodes=$NODE";
{code}
h3. Actual result

HTTP 500:
{code:json}
{
  "responseHeader": {"status": 500, "QTime": 77},
  "error": {
    "msg": "Error occurred while proxying to other node",
    "errorClass": "org.apache.solr.common.SolrException",
    "metadata": {"root-error-class": "java.lang.NullPointerException"}
  }
}
{code}
Stack trace bottoms out at:
{noformat}
org.apache.solr.handler.admin.api.GetNodeSystemInfo$1.processTypedProxiedResponse(GetNodeSystemInfo.java:80)
org.apache.solr.handler.admin.proxy.V2SolrRequestBasedProxy.processProxiedResponse(V2SolrRequestBasedProxy.java:77)
org.apache.solr.handler.admin.proxy.RemoteRequestProxy.bulkProcessResponses(RemoteRequestProxy.java:96)
org.apache.solr.handler.admin.proxy.RemoteRequestProxy.proxyRequest(RemoteRequestProxy.java:88)
org.apache.solr.handler.admin.api.GetNodeSystemInfo.proxyToNodes(GetNodeSystemInfo.java:83)
org.apache.solr.handler.admin.api.GetNodeSystemInfo.getNodeSystemInfo(GetNodeSystemInfo.java:57)
{noformat}
h3. Root cause

{{solr/api/src/java/org/apache/solr/client/api/model/NodeSystemResponse.java:32}}
 declares:
{code:java}
public Map<String, Object> remoteNodeData;
{code}
with no initializer and no constructor that populates it. 
{{{}GetNodeSystemInfo.java{}}}'s {{proxyToNodes}} (lines 70-83) creates a fresh 
response and its anonymous {{V2SolrRequestBasedProxy}} override does:
{code:java}
// GetNodeSystemInfo.java:78-81
public void processTypedProxiedResponse(String nodeName, NodeSystemResponse 
proxiedResponse) {
  response.remoteNodeData.put(nodeName, proxiedResponse);  // NPE: 
remoteNodeData is null
}
{code}
The same unguarded {{.put()}} also exists in 
{{NodeSystemResponse.setRemoteNodeResponse()}} (line 41, the Jackson 
{{{}@JsonAnySetter{}}}), which would NPE identically during deserialization of 
a response with unrecognized extra fields.
h3. Suggested fix

Initialize the field at declaration:
{code:java}
public Map<String, Object> remoteNodeData = new LinkedHashMap<>();
{code}
({{{}LinkedHashMap{}}} for stable node ordering, consistent with other response 
maps in this codebase; plain {{HashMap}} also resolves the crash if ordering 
isn't a concern.)
h3. Impact

Blocks migrating {{{}solr/webapp/web/js/angular/controllers/cloud.js{}}}'s 
"Cloud -> Nodes" admin UI page from the v1 {{System.get(

{nodes: ...}

)}} call to the v2 {{SystemV2.getNodeSystemInfo(

{nodes: ...}

)}} equivalent.

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to