Skip to content

SOLR-3284: fix RemoteSolrException NPE when remoteError is null#4637

Merged
dsmiley merged 2 commits into
apache:mainfrom
serhiy-bzhezytskyy:remotesolrexception-null-remoteerror-npe
Jul 16, 2026
Merged

SOLR-3284: fix RemoteSolrException NPE when remoteError is null#4637
dsmiley merged 2 commits into
apache:mainfrom
serhiy-bzhezytskyy:remotesolrexception-null-remoteerror-npe

Conversation

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor

Follow-up to the SOLR-3284 error path (David flagged this on #4632 as worth its own change).

RemoteSolrException(remoteHost, code, remoteError, skipRetry) built its details with Map.of(...), which rejects null values, so it threw NullPointerException when remoteError was null.

A null remoteError is expected: ConcurrentUpdateBaseSolrClient calls this constructor in a finally block with remoteError still null whenever a non-OK response has no parseable error body (a proxy 502/503, a truncated or non-Solr response). The NPE then masked the actual HTTP status the exception was meant to carry. HttpSolrClient has a similar call site.

Switched to Utils.makeMap (the map building idiom already used elsewhere in the code), which tolerates a null value. Added RemoteSolrExceptionTest covering the null case (the regression) plus the consumers of the resulting exception, and the non-null case.

The constructor built its details map with Map.of, which rejects null values,
so it threw NullPointerException when remoteError was null. That happens
whenever a non-OK response has no parseable error body (e.g. a proxy error),
where it masked the actual HTTP status. Use a null-tolerant map instead.

@dsmiley dsmiley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 thanks.

Prefer no changelog...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh... IMO it's minor enough as to not bother with a changelog. Besides, we have a separate SOLR-3284 linked changelog and I'm not sure we support this. The NPE fixed didn't even exist when SOLR-3284 was created so it's quite dubious to even associate it.

@dsmiley dsmiley added this to the 10.x milestone Jul 16, 2026
David preferred no changelog for this small NPE fix.
@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor Author

Removed the changelog entry.

Also checked the Crave CI red — it's IndexFetcherPacketProtocolTest (fetchPackets return code mismatch expected:<0> but was:<1>), all 14 failures in replication file-fetching. Unrelated to this change (a one-line null-guard in RemoteSolrException) and it passes locally, so looks like a flake on that test.

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor Author

correction on the CI red — it's not a flake. IndexFetcherPacketProtocolTest fails deterministically on clean main (no changes) with the CI seed 6FA33BD8BF6D0D4C, and passes with the default random seed, which is why it looked flaky at first. so it's a pre-existing seed-dependent failure on main, unrelated to this PR.

the return 1 is an Adler32 checksum mismatch in fetchPackets — looks like the SOLR-18098 packet test is fragile under certain randomized codecs. i'll file a separate issue for it.

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor Author

filed the fix for that pre-existing test failure: #4642 (SOLR-18098). forces an FS directory factory in IndexFetcherPacketProtocolTest so the randomized RAM directory doesn't hide the staged file. this PR's CI red was entirely that test.

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor Author

Update on that IndexFetcherPacketProtocolTest failure: it turned out Jason had already fixed it in #4624 (merged to main 07-15, using DirContext.REPLICATION). My #4642 was a duplicate and I've closed it. So this PR's CI just needs a run against current main — the flake is already fixed there.

@dsmiley
dsmiley merged commit 59b23fd into apache:main Jul 16, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants