Aias00 opened a new issue, #7476: URL: https://github.com/apache/shenyu/issues/7476
## Description The failover retry path assumes `UpstreamCacheManager.findUpstreamListBySelectorId(selectorId)` always returns a non-null list. If the selector's healthy-upstream list has been removed before the retry runs, the code calls `.stream()` on `null` and throws `NullPointerException`. ## Location - `shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/DefaultRetryStrategy.java:112` ## Expected Behavior A missing upstream list should be handled the same way as an empty upstream list: return the existing `CANNOT_FIND_HEALTHY_UPSTREAM_URL_AFTER_FAILOVER` failover exhaustion error. ## Actual Behavior The retry path throws an NPE: ```text java.lang.NullPointerException Cannot invoke "java.util.List.stream()" because the return value of "org.apache.shenyu.loadbalancer.cache.UpstreamCacheManager.findUpstreamListBySelectorId(String)" is null ``` ## Impact A normal runtime race, such as an upstream list being removed by sync or health state while an in-flight request is retrying, becomes an internal error rather than ShenYu's controlled failover response. ## Suggested Fix Store `findUpstreamListBySelectorId(selectorId)` in a local variable and null-check it before streaming. If it is null or empty, return the same `ShenyuException` used for an empty filtered list. Add a failover regression test with no upstream list for `DIVIDE_SELECTOR_ID`. ## Evidence - Scratch repro: `.omx/reports/code-review-batch20/http/repro/FailoverMissingUpstreamRepro.java` - Related existing distinction: #6734 covers missing failover trigger for 5xx responses; this issue is a null-list crash after failover is already triggered. ## Reviewed Revision And Validation Apache ShenYu 2.7.2-SNAPSHOT, master at a89b6a2338c24e978428b731e8f1edce86022418. Severity: medium. Confidence: high. Actual retry-strategy scratch harness reproduced missing upstream-list NPE. Dynamic configuration removal makes the inter-attempt state reachable. Current source references: - `shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/DefaultRetryStrategy.java:112` No implementation fix or full deployed end-to-end validation was performed by this review. Source-flow and runtime evidence are distinguished above. -- 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]
