Repository navigation
fix(httpclient): handle missing upstream list during failover - #7483
Merged
Merged
Conversation
Aias00
previously approved these changes
Oct 8, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Reviewed current head 7f0954df8cb0.
The failover retry path now handles a missing upstream list as an exhausted failover instead of throwing a null-pointer error. No blocking issue found.
Validation: exact-head targeted Maven reactor tests passed on Java 17.
./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient -am test -Dtest=RetryStrategyTest,WebClientPluginTest -Dsurefire.failIfNoSpecifiedTests=false -Drat.skip=true -Djacoco.skip=true -DskipRemoteResources=true -Dmaven.javadoc.skip=true
Aias00
approved these changes
Oct 11, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Summary
Correct fix. When findUpstreamListBySelectorId returns null during failover, DefaultRetryStrategy.resend now fails cleanly with ShenyuException, which is mapped to a 503 ResponseStatusException by the existing onErrorMap (DefaultRetryStrategy.java:89) — instead of blowing up with an NPE. Both added tests assert the 503 path.
Approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7476
Problem
With the
failoverretry strategy explicitly selected (the default iscurrent) and the rule's default retry count of 3, an in-flight request can retry after its selector’s upstream cache entry has been removed.The removal path is
removeByKey → triggerRemoveAll → healthyUpstream.remove. It is reached when a selector is deleted, discovery upstream data is deleted, or an upstream update supplies an empty list.UpstreamCacheManager.findUpstreamListBySelectorId()then returnsnull, butDefaultRetryStrategycalls.stream()directly on that result.Health-check status changes do not remove the key: they remove individual list elements, leaving an empty list that already follows the controlled 503 exhaustion path.
Both WebClient and Netty convert upstream 5xx responses into error signals in failover mode, so a connection failure or timeout is not required.
Impact
The NPE escapes the existing error mappings and reaches
GlobalErrorHandler, producing HTTP 500 with the default JSON response{"code":500,"message":"Internal Server Error"}and invokingAlarmSender.alarmMediumCritical("ShenYu-Gateway-Global-Error", ...).Both HTTP client plugins are affected when using
DefaultRetryStrategyto retry after a cache-entry removal.The fix restores the existing HTTP 503 response with reason
CANNOT_FIND_HEALTHY_UPSTREAM_URL_AFTER_FAILOVER. The global handler also invokes its alarm for this controlled response.Changes
nullbefore streaming.CANNOT_FIND_HEALTHY_UPSTREAM_URL_AFTER_FAILOVERexception for a missing list.Validation
expectErrorSatisfiesassertions because they receivedNullPointerExceptioninstead ofResponseStatusException; after the fix, all 41 module tests passed with zero failures or errors.Checklist
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.