nick-boss-tech opened a new pull request, #5155: URL: https://github.com/apache/solr/pull/5155
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-8051 ## What happens today **A shard with no response makes the global stats merge throw a NullPointerException.** When no server answers for a shard, that shard's response has no body. The merge loop calls `getException()` on the response first ([ExactStatsCache.java lines 116-120 at the merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java#L116-L120)). That method reads the body before anything checks for it ([SolrResponse.java lines 48-49 at the merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java#L48-L49)). The merge-base has no check for a missing body before that call. ## What this change does **A shard with no response is now skipped in the global stats merge.** - The merge reads the response body first and skips the shard when the body is missing ([ExactStatsCache.java lines 116-126 at the head](https://github.com/nick-boss-tech/solr/blob/65d0c968d8a41f949cf7564df896827ec112c8dc/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java#L116-L126)). - A shard that returned an error was already skipped at that point. The new check follows the same rule. - The skipped shard's term statistics are left out of the global merge. Only a debug log line records it. ## Proof **A new test fails on the base code and passes with this change.** - `ExactStatsCacheMergeTest.testShardWithoutResponseIsSkipped` ([test lines 28-36](https://github.com/nick-boss-tech/solr/blob/65d0c968d8a41f949cf7564df896827ec112c8dc/solr/core/src/test/org/apache/solr/search/stats/ExactStatsCacheMergeTest.java#L28-L36)) gives the merge a shard response with no body and no error, then runs the merge. - Verified 2026-10-09 at head 65d0c968d8a4, which has the same content as e50a2aa3437c: ExactStatsCacheMergeTest 1 of 1. On the base code the failure is the NullPointerException in the global stats merge. ## Limits **The test checks that the merge does not throw. It does not check the global stats values.** - The test has no assertion. It passes when the call returns without an exception. - [SOLR-15319](https://issues.apache.org/jira/browse/SOLR-15319) lands after this change. Its branch has the same null-response path and does not fix it. If the two edits to `ExactStatsCache` overlap, that branch is rebased onto this one. Changelog: [changelog/unreleased/SOLR-8051-exact-stats-missing-shard.yml](https://github.com/nick-boss-tech/solr/blob/65d0c968d8a41f949cf7564df896827ec112c8dc/changelog/unreleased/SOLR-8051-exact-stats-missing-shard.yml) ### AI assistance AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
