-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: enhancementA general enhancementA general enhancement
Milestone
Description
The DefaultWebClientBuilder is copying references (e.g.defaul;tHeaders) to the built WebClient instance. This prevents reuse of the WebClient, as changing the content in the builder will also change the content in already created instances.
When the following snippet is used, both webClients will have the same defaultHeaders (i.e. X=second)
WebClient.Builder builder = WebClient.builder();
WebClient first = builder.defaultHeaders(h -> h.set("X", "first")).build;
WebClient second = builder.defaultHeaders(h -> h.set("X", "second")).build;
This can be experienced in Spring 5.2.8, but should be in the 5.3.0 as well.
It can be worked around by cloning the builder before change.
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: enhancementA general enhancementA general enhancement