-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebClient and RestClient's defaultRequest(..) is not invoked early enough #32053
Comments
FYI, I found this issue while investigating #32028 😃 If this behavior of |
WebClient
and RestClient
's defaultRequest(..)
behavior about setting default valuesWebClient
and RestClient
's defaultRequest(..)
behavior about setting default values
Thanks for spotting this odd behavior, which is indeed not intentional. However, the fact remains that the current behavior has been present since 5.0, and changing it, to do effectively the opposite of what it is currently doing, can affect many users. Fixing this issue is trivial—I have a fix locally—but that fix won't be merged until 6.2. |
Note that—even though this is a bug—it will not be backported to the 6.1, 6.0, or 5.3 branches, as it fixing it will break backward compatibility. |
Aha I understood! I agree with your opinion. I just wondered it's bug or intended behavior. Anyway I'm glad to found this trivial bug, and please share if there's something I can help~ thanks! 🙇 |
WebClient
and RestClient
's defaultRequest(..)
behavior about setting default valuesWebClient
and RestClient
's defaultRequest(..)
is not invoked early enough
WebClient
and RestClient
's defaultRequest(..)
is not invoked early enough
Background
WebClient
andRestClient
havedefault[Header|Cookie|Request|..]
that useful to setdefault value
on request.spring-framework/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
Lines 502 to 508 in 899de4f
As you can see above code,
defaultHeader
value is set only when it's not contained in headers.Question
spring-framework/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
Lines 481 to 484 in 899de4f
But on
defaultRequest(..)
, it can override request's values unlikedefaultHeader
cause it's called on every request being built.Reproduce
I think
defaultRequest(spec -> spec.accept(MEDIA_TYPE))
will override all media types that set byaccept(..)
on this request.Q. is above behavior of
defaultRequest(..)
is intended? thanks!The text was updated successfully, but these errors were encountered: