Polishing

This commit is contained in:
Juergen Hoeller 2020-06-06 16:10:20 +02:00
parent 5051d7302d
commit 65b09be669
3 changed files with 16 additions and 9 deletions

View File

@ -79,7 +79,7 @@ public class DefaultResourceLoader implements ResourceLoader {
* Specify the ClassLoader to load class path resources with, or {@code null}
* for using the thread context class loader at the time of actual resource access.
* <p>The default is that ClassLoader access will happen using the thread context
* class loader at the time of this ResourceLoader's initialization.
* class loader at the time of actual resource access (since 5.3).
*/
public void setClassLoader(@Nullable ClassLoader classLoader) {
this.classLoader = classLoader;

View File

@ -1768,6 +1768,19 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
}
/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers, if necessary.
* <p>Also caches the parsed representations of the "Accept" and "Content-Type" headers.
* @param headers the headers to expose
* @return a read-only variant of the headers, or the original headers as-is
* (in case it happens to be a read-only {@code HttpHeaders} instance already)
* @since 5.3
*/
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
return (headers instanceof HttpHeaders ?
readOnlyHttpHeaders((HttpHeaders) headers) : new ReadOnlyHttpHeaders(headers));
}
/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers, if necessary.
* <p>Also caches the parsed representations of the "Accept" and "Content-Type" headers.

View File

@ -229,7 +229,7 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
}
@Override
@SuppressWarnings("deprecation")
@Deprecated
public WebClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer) {
if (this.strategiesConfigurers == null) {
this.strategiesConfigurers = new ArrayList<>(4);
@ -266,7 +266,7 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
.orElse(exchange) : exchange);
return new DefaultWebClient(filteredExchange, initUriBuilderFactory(),
this.defaultHeaders != null ? HttpHeaders.readOnlyHttpHeaders(this.defaultHeaders) : null,
this.defaultCookies != null ? HttpHeaders.readOnlyHttpHeaders(this.defaultCookies) : null,
this.defaultCookies != null ? CollectionUtils.unmodifiableMultiValueMap(this.defaultCookies) : null,
this.defaultRequest, new DefaultWebClientBuilder(this));
}
@ -290,10 +290,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
if (CollectionUtils.isEmpty(this.strategiesConfigurers)) {
return this.strategies != null ? this.strategies : ExchangeStrategies.withDefaults();
}
ExchangeStrategies.Builder builder =
this.strategies != null ? this.strategies.mutate() : ExchangeStrategies.builder();
this.strategiesConfigurers.forEach(configurer -> configurer.accept(builder));
return builder.build();
}
@ -308,8 +306,4 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
return factory;
}
private static <K, V> MultiValueMap<K, V> unmodifiableCopy(MultiValueMap<K, V> map) {
return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(map));
}
}