Add cloneBuilder method on WebClient.Builder

This commit adds a new `cloneBuilder()` method on `WebClient.Builder`;
we can now reuse the customizations of an existing builder without
sharing its state across several `WebClient` building code paths.

Issue: SPR-15690
This commit is contained in:
Brian Clozel
2017-06-22 18:00:11 +02:00
committed by Rossen Stoyanchev
parent 8fc3b3bc37
commit 8ac29c8ce7
2 changed files with 10 additions and 0 deletions

View File

@@ -92,6 +92,11 @@ class DefaultWebClientBuilder implements WebClient.Builder {
return this;
}
@Override
public WebClient.Builder cloneBuilder() {
return new DefaultWebClientBuilder(this);
}
@Override
public WebClient.Builder defaultUriVariables(Map<String, ?> defaultUriVariables) {
this.defaultUriVariables = defaultUriVariables;

View File

@@ -192,6 +192,11 @@ public interface WebClient {
*/
Builder baseUrl(String baseUrl);
/**
* Clone this {@code WebClient.Builder}
*/
Builder cloneBuilder();
/**
* Configure default URI variable values that will be used when expanding
* URI templates using a {@link Map}.