diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java index be242c2aff2..c8796e91f78 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,11 +66,11 @@ final class DefaultWebClientBuilder implements WebClient.Builder { @Nullable private ClientHttpConnector connector; + private ExchangeStrategies exchangeStrategies; + @Nullable private ExchangeFunction exchangeFunction; - private ExchangeStrategies exchangeStrategies; - public DefaultWebClientBuilder() { this.exchangeStrategies = ExchangeStrategies.withDefaults(); @@ -80,8 +80,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder { Assert.notNull(other, "DefaultWebClientBuilder must not be null"); this.baseUrl = other.baseUrl; - this.defaultUriVariables = - other.defaultUriVariables != null ? new LinkedHashMap<>(other.defaultUriVariables) : null; + this.defaultUriVariables = (other.defaultUriVariables != null ? + new LinkedHashMap<>(other.defaultUriVariables) : null); this.uriBuilderFactory = other.uriBuilderFactory; if (other.defaultHeaders != null) { this.defaultHeaders = new HttpHeaders(); @@ -90,13 +90,13 @@ final class DefaultWebClientBuilder implements WebClient.Builder { else { this.defaultHeaders = null; } - this.defaultCookies = - other.defaultCookies != null ? new LinkedMultiValueMap<>(other.defaultCookies) : null; + this.defaultCookies = (other.defaultCookies != null ? + new LinkedMultiValueMap<>(other.defaultCookies) : null); this.defaultRequest = other.defaultRequest; this.filters = other.filters != null ? new ArrayList<>(other.filters) : null; this.connector = other.connector; - this.exchangeFunction = other.exchangeFunction; this.exchangeStrategies = other.exchangeStrategies; + this.exchangeFunction = other.exchangeFunction; } @@ -163,12 +163,6 @@ final class DefaultWebClientBuilder implements WebClient.Builder { return this; } - @Override - public WebClient.Builder clientConnector(ClientHttpConnector connector) { - this.connector = connector; - return this; - } - @Override public WebClient.Builder filter(ExchangeFilterFunction filter) { Assert.notNull(filter, "ExchangeFilterFunction must not be null"); @@ -190,8 +184,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder { } @Override - public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) { - this.exchangeFunction = exchangeFunction; + public WebClient.Builder clientConnector(ClientHttpConnector connector) { + this.connector = connector; return this; } @@ -202,6 +196,23 @@ final class DefaultWebClientBuilder implements WebClient.Builder { return this; } + @Override + public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) { + this.exchangeFunction = exchangeFunction; + return this; + } + + @Override + public WebClient.Builder apply(Consumer builderConsumer) { + builderConsumer.accept(this); + return this; + } + + @Override + public WebClient.Builder clone() { + return new DefaultWebClientBuilder(this); + } + @Override public WebClient build() { ExchangeFunction exchange = initExchangeFunction(); @@ -245,15 +256,4 @@ final class DefaultWebClientBuilder implements WebClient.Builder { return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(map)); } - @Override - public WebClient.Builder clone() { - return new DefaultWebClientBuilder(this); - } - - @Override - public WebClient.Builder apply(Consumer builderConsumer) { - builderConsumer.accept(this); - return this; - } - } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 72eb9fc97ad..8dc2a17c012 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -303,11 +303,6 @@ public interface WebClient { */ Builder exchangeFunction(ExchangeFunction exchangeFunction); - /** - * Clone this {@code WebClient.Builder}. - */ - Builder clone(); - /** * Apply the given {@code Consumer} to this builder instance. *

This can be useful for applying pre-packaged customizations. @@ -315,17 +310,20 @@ public interface WebClient { */ Builder apply(Consumer builderConsumer); + /** + * Clone this {@code WebClient.Builder}. + */ + Builder clone(); + /** * Builder the {@link WebClient} instance. */ WebClient build(); - } /** * Contract for specifying the URI for a request. - * * @param a self reference to the spec type */ interface UriSpec> { @@ -359,7 +357,6 @@ public interface WebClient { /** * Contract for specifying request headers leading up to the exchange. - * * @param a self reference to the spec type */ interface RequestHeadersSpec> { @@ -525,9 +522,9 @@ public interface WebClient { * {@linkplain BodyInserters#fromPublisher Publisher inserter}. * For example: *

-		 * Mono personMono = ... ;
+		 * Mono<Person> personMono = ... ;
 		 *
-		 * Mono result = client.post()
+		 * Mono<Void> result = client.post()
 		 *     .uri("/persons/{id}", id)
 		 *     .contentType(MediaType.APPLICATION_JSON)
 		 *     .body(personMono, Person.class)