Julian Chandra Sutadi created SOLR-18596:
--------------------------------------------
Summary: NullPointerException in QueryComponent.returnFields on a
cause-less SolrServerException
Key: SOLR-18596
URL: https://issues.apache.org/jira/browse/SOLR-18596
Project: Solr
Issue Type: Bug
Reporter: Julian Chandra Sutadi
SOLR-17209 fixed a {{NullPointerException}} in {{QueryComponent.mergeIds}} that
occurs when a shard fails with a {{SolrServerException}} whose cause is
{{null}}. However, an identical unguarded unwrap still exists in the sibling
method {{QueryComponent.returnFields}} and was not covered by that fix.
Under the same condition, it can throw the same NPE during the GET_FIELDS phase
of a distributed search. For instance, consider a distributed sharded query
which has finished the first phase. In the second phase, with
{{shards.info=true}}, the coordinator records a per-shard error instead of
failing the whole request, which unwraps a shard's {{SolrServerException}} to
its cause before stringifying it.
The unwrap, however, assumes that {{SolrServerException}} always wraps a cause.
{{LBSolrClient}} violates that assumption on the "time allowed exceeded" and
"no live servers" paths. In those paths, it constructs the exception with no
cause
{code:java}
// LBSolrClient.java
if (ex == null) {
throw new SolrServerException(solrServerExceptionMessage); // no cause
} else {
throw new SolrServerException(solrServerExceptionMessage, ex);
}
{code}
Then, we will encounter NPE
{code:java}
// in QueryComponent#returnFields
if (nl.get("error") == null) {
// Add the error to the shards info section if it wasn't added before
Throwable t = srsp.getException();
if (t instanceof SolrServerException) { // no null-cause check
t = ((SolrServerException) t).getCause(); // t can become null
}
nl.add("error", t.toString()); // NPE when t == null
if (!rb.req.getCore().getCoreContainer().hideStackTrace()) {
StringWriter trace = new StringWriter();
t.printStackTrace(new PrintWriter(trace));
...
}
}
{code}
I'll attach a PR soon
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]