GH-3168: Document that @LoadBalanced RestClient must not be used in Gateway MVC#4200
Open
won-seoop wants to merge 1 commit into
Open
GH-3168: Document that @LoadBalanced RestClient must not be used in Gateway MVC#4200won-seoop wants to merge 1 commit into
won-seoop wants to merge 1 commit into
Conversation
…sed with Gateway MVC Document that a custom @LoadBalanced RestClient.Builder bean in the same application context as the gateway will intercept the gateway's internal proxy requests, causing an IllegalArgumentException: Service Instance cannot be null before the lb() filter can resolve the target. Users should rely only on the lb() filter or lb:// URI scheme for load-balanced routing within the gateway; @LoadBalanced is for beans that application code calls directly, not the gateway proxy client. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Closes #3168
When a
@LoadBalanced RestClient.Builderbean exists in the same application context as Spring Cloud Gateway Server MVC, Spring Cloud LoadBalancer intercepts the gateway's internal proxyRestClientrequests before thelb()filter resolves the service instance — causingIllegalArgumentException: Service Instance cannot be null.This was confirmed by @spencergibb in the issue: "Any
RestClientbean used by Gateway MVC should NOT be@LoadBalancedas there is a separatelb()filter for that."This PR adds a
[[loadbalancer-restclient-warning]]section toloadbalancer.adocthat:@LoadBalancedintercepts all outboundRestClientcalls, including the gateway's internal proxy clientService Instance cannot be null)lb()filter orlb://URI scheme for gateway routes, and reserve@LoadBalancedfor beans their own code calls directlyTest plan
🤖 Generated with Claude Code