diff --git a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java index 1835f288e34..77bf1c4d73f 100644 --- a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java @@ -125,14 +125,10 @@ public final class MultipartBodyBuilder { * @param elementClass the type of elements contained in the publisher * @return builder that allows for further customization of part headers */ - public > PartBuilder asyncPart(String name, P publisher, - Class elementClass) { - - Assert.notNull(elementClass, "'elementClass' must not be null"); - ResolvableType elementType = ResolvableType.forClass(elementClass); + public > PartBuilder asyncPart(String name, P publisher, Class elementClass) { Assert.hasLength(name, "'name' must not be empty"); Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(elementType, "'elementType' must not be null"); + Assert.notNull(elementClass, "'elementClass' must not be null"); HttpHeaders headers = new HttpHeaders(); PublisherPartBuilder builder = new PublisherPartBuilder<>(headers, publisher, elementClass); @@ -150,14 +146,12 @@ public final class MultipartBodyBuilder { * @param typeReference the type of elements contained in the publisher * @return builder that allows for further customization of part headers */ - public > PartBuilder asyncPart(String name, P publisher, - ParameterizedTypeReference typeReference) { + public > PartBuilder asyncPart( + String name, P publisher, ParameterizedTypeReference typeReference) { - Assert.notNull(typeReference, "'typeReference' must not be null"); - ResolvableType elementType1 = ResolvableType.forType(typeReference); Assert.hasLength(name, "'name' must not be empty"); Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(elementType1, "'typeReference' must not be null"); + Assert.notNull(typeReference, "'typeReference' must not be null"); HttpHeaders headers = new HttpHeaders(); PublisherPartBuilder builder = new PublisherPartBuilder<>(headers, publisher, typeReference); @@ -210,7 +204,6 @@ public final class MultipartBodyBuilder { @Nullable protected final Object body; - public DefaultPartBuilder(HttpHeaders headers, @Nullable Object body) { this.headers = headers; this.body = body; @@ -224,7 +217,6 @@ public final class MultipartBodyBuilder { @Override public PartBuilder headers(Consumer headersConsumer) { - Assert.notNull(headersConsumer, "'headersConsumer' must not be null"); headersConsumer.accept(this.headers); return this; } @@ -239,7 +231,6 @@ public final class MultipartBodyBuilder { private final ResolvableType resolvableType; - public PublisherPartBuilder(HttpHeaders headers, P body, Class elementClass) { super(headers, body); this.resolvableType = ResolvableType.forClass(elementClass); @@ -255,12 +246,11 @@ public final class MultipartBodyBuilder { this.resolvableType = other.getResolvableType(); } - @Override @SuppressWarnings("unchecked") public HttpEntity build() { P publisher = (P) this.body; - Assert.state(publisher != null, "'publisher' must not be null"); + Assert.state(publisher != null, "Publisher must not be null"); return new PublisherEntity<>(this.headers, publisher, this.resolvableType); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/HttpHeadResponseDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/HttpHeadResponseDecorator.java index f6186877433..246cd60be75 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/HttpHeadResponseDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/HttpHeadResponseDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.http.server.reactive; import java.util.function.BiFunction; @@ -32,7 +33,6 @@ import org.springframework.core.io.buffer.DataBufferUtils; */ public class HttpHeadResponseDecorator extends ServerHttpResponseDecorator { - public HttpHeadResponseDecorator(ServerHttpResponse delegate) { super(delegate); } @@ -45,9 +45,7 @@ public class HttpHeadResponseDecorator extends ServerHttpResponseDecorator { */ @Override public final Mono writeWith(Publisher body) { - // After Reactor Netty #171 is fixed we can return without delegating - return getDelegate().writeWith( Flux.from(body) .reduce(0, (current, buffer) -> { @@ -61,7 +59,6 @@ public class HttpHeadResponseDecorator extends ServerHttpResponseDecorator { /** * Invoke {@link #setComplete()} without writing. - * *

RFC 7302 allows HTTP HEAD response without content-length and it's not * something that can be computed on a streaming response. */ diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java index 9ba1cd1fc24..f1d09f59083 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -43,7 +43,7 @@ public class ServerHttpRequestDecorator implements ServerHttpRequest { public ServerHttpRequestDecorator(ServerHttpRequest delegate) { - Assert.notNull(delegate, "ServerHttpRequest delegate is required."); + Assert.notNull(delegate, "Delegate is required"); this.delegate = delegate; } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java index abfeb9eb888..ae95e919ca8 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -42,7 +42,7 @@ public class ServerHttpResponseDecorator implements ServerHttpResponse { public ServerHttpResponseDecorator(ServerHttpResponse delegate) { - Assert.notNull(delegate, "ServerHttpResponse delegate is required."); + Assert.notNull(delegate, "Delegate is required"); this.delegate = delegate; } diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 41dede580bb..54270ebe85e 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -310,7 +310,8 @@ public class PathPattern implements Comparable { } } resultPath = PathContainer.parsePath(buf.toString()); - } else if (startIndex >= endIndex) { + } + else if (startIndex >= endIndex) { resultPath = PathContainer.parsePath(""); } else { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index 5c043d0a298..05a636c99b1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java @@ -212,7 +212,7 @@ public abstract class BodyInserters { * @return the inserter that allows adding more form data */ public static FormInserter fromFormData(String name, String value) { - Assert.notNull(name, "'key' must not be null"); + Assert.notNull(name, "'name' must not be null"); Assert.notNull(value, "'value' must not be null"); return new DefaultFormInserter().with(name, value); } @@ -221,11 +221,9 @@ public abstract class BodyInserters { * Return a {@link MultipartInserter} that writes the given * {@code MultiValueMap} as multipart data. Values in the map can be an * Object or an {@link HttpEntity}. - * *

Note that you can also build the multipart data externally with * {@link MultipartBodyBuilder}, and pass the resulting map directly to the * {@code syncBody(Object)} shortcut method in {@code WebClient}. - * * @param multipartData the form data to write to the output message * @return the inserter that allows adding more parts * @see MultipartBodyBuilder @@ -239,17 +237,15 @@ public abstract class BodyInserters { * Return a {@link MultipartInserter} that writes the given parts, * as multipart data. Values in the map can be an Object or an * {@link HttpEntity}. - * *

Note that you can also build the multipart data externally with * {@link MultipartBodyBuilder}, and pass the resulting map directly to the * {@code syncBody(Object)} shortcut method in {@code WebClient}. - * * @param name the part name * @param value the part value, an Object or {@code HttpEntity} * @return the inserter that allows adding more parts */ public static MultipartInserter fromMultipartData(String name, Object value) { - Assert.notNull(name, "'key' must not be null"); + Assert.notNull(name, "'name' must not be null"); Assert.notNull(value, "'value' must not be null"); return new DefaultMultipartInserter().with(name, value); } @@ -257,22 +253,16 @@ public abstract class BodyInserters { /** * Return a {@link MultipartInserter} that writes the given asynchronous parts, * as multipart data. - * *

Note that you can also build the multipart data externally with * {@link MultipartBodyBuilder}, and pass the resulting map directly to the * {@code syncBody(Object)} shortcut method in {@code WebClient}. - * * @param name the part name * @param publisher the publisher that forms the part value * @param elementClass the class contained in the {@code publisher} * @return the inserter that allows adding more parts */ - public static > MultipartInserter fromMultipartAsyncData(String name, - P publisher, Class elementClass) { - - Assert.notNull(name, "'key' must not be null"); - Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(elementClass, "'elementClass' must not be null"); + public static > MultipartInserter fromMultipartAsyncData( + String name, P publisher, Class elementClass) { return new DefaultMultipartInserter().withPublisher(name, publisher, elementClass); } @@ -281,22 +271,16 @@ public abstract class BodyInserters { * Variant of {@link #fromMultipartAsyncData(String, Publisher, Class)} that * accepts a {@link ParameterizedTypeReference} for the element type, which * allows specifying generic type information. - * *

Note that you can also build the multipart data externally with * {@link MultipartBodyBuilder}, and pass the resulting map directly to the * {@code syncBody(Object)} shortcut method in {@code WebClient}. - * * @param name the part name * @param publisher the publisher that forms the part value * @param typeReference the type contained in the {@code publisher} * @return the inserter that allows adding more parts */ - public static > MultipartInserter fromMultipartAsyncData(String name, - P publisher, ParameterizedTypeReference typeReference) { - - Assert.notNull(name, "'key' must not be null"); - Assert.notNull(publisher, "'publisher' must not be null"); - Assert.notNull(typeReference, "'typeReference' must not be null"); + public static > MultipartInserter fromMultipartAsyncData( + String name, P publisher, ParameterizedTypeReference typeReference) { return new DefaultMultipartInserter().withPublisher(name, publisher, typeReference); } @@ -312,7 +296,7 @@ public abstract class BodyInserters { public static > BodyInserter fromDataBuffers( T publisher) { - Assert.notNull(publisher, "'publisher' must not be null"); + Assert.notNull(publisher, "Publisher must not be null"); return (outputMessage, context) -> outputMessage.writeWith(publisher); } @@ -333,9 +317,9 @@ public abstract class BodyInserters { return messageWriter.write(body, bodyType, bodyType, contentType, serverRequest.get(), (ServerHttpResponse) outputMessage, context.hints()); - } else { - return messageWriter.write(body, bodyType, contentType, outputMessage, - context.hints()); + } + else { + return messageWriter.write(body, bodyType, contentType, outputMessage, context.hints()); } }) .orElseGet(() -> { @@ -500,4 +484,5 @@ public abstract class BodyInserters { outputMessage, context.hints()); } } + } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java index b9fb4a78bc5..14901d541e1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java @@ -28,7 +28,6 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.client.reactive.ClientHttpRequest; -import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyInserter; @@ -109,7 +108,6 @@ public interface ClientRequest { * @return the created builder */ static Builder from(ClientRequest other) { - Assert.notNull(other, "'other' must not be null"); return new DefaultClientRequestBuilder(other); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 15251067e64..ae2c0518460 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -35,7 +35,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.client.reactive.ClientHttpResponse; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyExtractor; @@ -160,7 +159,6 @@ public interface ClientResponse { * @return the created builder */ static Builder from(ClientResponse other) { - Assert.notNull(other, "Other ClientResponse must not be null"); return new DefaultClientResponseBuilder(other); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java index 91aa4e873f3..bd3e6bd8e50 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java @@ -47,7 +47,7 @@ import org.springframework.web.reactive.function.BodyInserters; * @author Arjen Poutsma * @since 5.0 */ -class DefaultClientRequestBuilder implements ClientRequest.Builder { +final class DefaultClientRequestBuilder implements ClientRequest.Builder { private final HttpHeaders headers = new HttpHeaders(); @@ -63,18 +63,21 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { public DefaultClientRequestBuilder(HttpMethod method, URI url) { - this.method = method; - this.url = url; + method(method); + url(url); } public DefaultClientRequestBuilder(ClientRequest other) { - this(other.method(), other.url()); + Assert.notNull(other, "ClientRequest must not be null"); + method(other.method()); + url(other.url()); headers(headers -> headers.addAll(other.headers())); cookies(cookies -> cookies.addAll(other.cookies())); attributes(attributes -> attributes.putAll(other.attributes())); body(other.body()); } + @Override public ClientRequest.Builder method(HttpMethod method) { Assert.notNull(method, "'method' must not be null"); @@ -99,7 +102,6 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @Override public ClientRequest.Builder headers(Consumer headersConsumer) { - Assert.notNull(headersConsumer, "'headersConsumer' must not be null"); headersConsumer.accept(this.headers); return this; } @@ -114,7 +116,6 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @Override public ClientRequest.Builder cookies(Consumer> cookiesConsumer) { - Assert.notNull(cookiesConsumer, "'cookiesConsumer' must not be null"); cookiesConsumer.accept(this.cookies); return this; } @@ -129,8 +130,8 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { } @Override - public > ClientRequest.Builder body(P publisher, - ParameterizedTypeReference typeReference) { + public > ClientRequest.Builder body( + P publisher, ParameterizedTypeReference typeReference) { Assert.notNull(publisher, "'publisher' must not be null"); Assert.notNull(typeReference, "'typeReference' must not be null"); @@ -147,7 +148,6 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @Override public ClientRequest.Builder attributes(Consumer> attributesConsumer) { - Assert.notNull(attributesConsumer, "'attributesConsumer' must not be null"); attributesConsumer.accept(this.attributes); return this; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java index 39b4e5e7d1b..5e5a2451316 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java @@ -40,7 +40,7 @@ import org.springframework.util.MultiValueMap; * @author Arjen Poutsma * @since 5.0.5 */ -class DefaultClientResponseBuilder implements ClientResponse.Builder { +final class DefaultClientResponseBuilder implements ClientResponse.Builder { private final HttpHeaders headers = new HttpHeaders(); @@ -59,7 +59,8 @@ class DefaultClientResponseBuilder implements ClientResponse.Builder { } public DefaultClientResponseBuilder(ClientResponse other) { - this(other.strategies()); + Assert.notNull(other, "ClientResponse must not be null"); + this.strategies = other.strategies(); statusCode(other.statusCode()); headers(headers -> headers.addAll(other.headers().asHttpHeaders())); cookies(cookies -> cookies.addAll(other.cookies())); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java index e034dcc1cf4..eaff0e8dbe1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultExchangeStrategiesBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -24,7 +24,6 @@ import java.util.function.Consumer; import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.util.Assert; /** * Default implementation of {@link ExchangeStrategies.Builder}. @@ -32,7 +31,7 @@ import org.springframework.util.Assert; * @author Arjen Poutsma * @since 5.0 */ -class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Builder { +final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Builder { private final ClientCodecConfigurer codecConfigurer = ClientCodecConfigurer.create(); @@ -41,13 +40,13 @@ class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Builder { this.codecConfigurer.registerDefaults(false); } + public void defaultConfiguration() { this.codecConfigurer.registerDefaults(true); } @Override public ExchangeStrategies.Builder codecs(Consumer consumer) { - Assert.notNull(consumer, "'consumer' must not be null"); consumer.accept(this.codecConfigurer); return this; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java index fe61b4eaee8..3cac85cfc6b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java @@ -215,7 +215,6 @@ class DefaultWebClient implements WebClient { @Override public DefaultRequestBodyUriSpec headers(Consumer headersConsumer) { - Assert.notNull(headersConsumer, "'headersConsumer' must not be null"); headersConsumer.accept(getHeaders()); return this; } @@ -228,7 +227,6 @@ class DefaultWebClient implements WebClient { @Override public RequestBodySpec attributes(Consumer> attributesConsumer) { - Assert.notNull(attributesConsumer, "'attributesConsumer' must not be null"); attributesConsumer.accept(this.attributes); return this; } @@ -265,7 +263,6 @@ class DefaultWebClient implements WebClient { @Override public DefaultRequestBodyUriSpec cookies(Consumer> cookiesConsumer) { - Assert.notNull(cookiesConsumer, "'cookiesConsumer' must not be null"); cookiesConsumer.accept(getCookies()); return this; } @@ -378,7 +375,6 @@ class DefaultWebClient implements WebClient { private List statusHandlers = new ArrayList<>(1); - DefaultResponseSpec(Mono responseMono) { this.responseMono = responseMono; this.statusHandlers.add(DEFAULT_STATUS_HANDLER); @@ -388,13 +384,9 @@ class DefaultWebClient implements WebClient { public ResponseSpec onStatus(Predicate statusPredicate, Function> exceptionFunction) { - Assert.notNull(statusPredicate, "'statusPredicate' must not be null"); - Assert.notNull(exceptionFunction, "'exceptionFunction' must not be null"); - if (this.statusHandlers.size() == 1 && this.statusHandlers.get(0) == DEFAULT_STATUS_HANDLER) { this.statusHandlers.clear(); } - this.statusHandlers.add(new StatusHandler(statusPredicate, exceptionFunction)); return this; @@ -476,6 +468,7 @@ class DefaultWebClient implements WebClient { }); } + private static class StatusHandler { private final Predicate predicate; @@ -484,6 +477,9 @@ class DefaultWebClient implements WebClient { public StatusHandler(Predicate predicate, Function> exceptionFunction) { + + Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(exceptionFunction, "Function must not be null"); this.predicate = predicate; this.exceptionFunction = exceptionFunction; } @@ -496,6 +492,6 @@ class DefaultWebClient implements WebClient { return this.exceptionFunction.apply(response); } } - } + } 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 6656b723def..773a99628c1 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-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -40,7 +40,7 @@ import org.springframework.web.util.UriBuilderFactory; * @author Rossen Stoyanchev * @since 5.0 */ -class DefaultWebClientBuilder implements WebClient.Builder { +final class DefaultWebClientBuilder implements WebClient.Builder { @Nullable private String baseUrl; @@ -74,7 +74,7 @@ class DefaultWebClientBuilder implements WebClient.Builder { } public DefaultWebClientBuilder(DefaultWebClientBuilder other) { - Assert.notNull(other, "'other' must not be null"); + Assert.notNull(other, "DefaultWebClientBuilder must not be null"); this.baseUrl = other.baseUrl; this.defaultUriVariables = (other.defaultUriVariables != null ? @@ -125,7 +125,6 @@ class DefaultWebClientBuilder implements WebClient.Builder { @Override public WebClient.Builder defaultHeaders(Consumer headersConsumer) { - Assert.notNull(headersConsumer, "'headersConsumer' must not be null"); headersConsumer.accept(initHeaders()); return this; } @@ -145,7 +144,6 @@ class DefaultWebClientBuilder implements WebClient.Builder { @Override public WebClient.Builder defaultCookies(Consumer> cookiesConsumer) { - Assert.notNull(cookiesConsumer, "Cookies consumer must not be null"); cookiesConsumer.accept(initCookies()); return this; } @@ -172,7 +170,6 @@ class DefaultWebClientBuilder implements WebClient.Builder { @Override public WebClient.Builder filters(Consumer> filtersConsumer) { - Assert.notNull(filtersConsumer, "Filters consumer must not be null"); filtersConsumer.accept(initFilters()); return this; } @@ -214,7 +211,8 @@ class DefaultWebClientBuilder implements WebClient.Builder { HttpHeaders copy = new HttpHeaders(); copy.putAll(original); return HttpHeaders.readOnlyHttpHeaders(copy); - } else { + } + else { return null; } } @@ -259,8 +257,6 @@ class DefaultWebClientBuilder implements WebClient.Builder { @Override public WebClient.Builder apply(Consumer builderConsumer) { - Assert.notNull(builderConsumer, "'builderConsumer' must not be null"); - builderConsumer.accept(this); return this; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunction.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunction.java index 75b2dd3f0ed..6e96bf4ce16 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunction.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -50,7 +50,7 @@ public interface ExchangeFilterFunction { * {@code after} function */ default ExchangeFilterFunction andThen(ExchangeFilterFunction after) { - Assert.notNull(after, "'after' must not be null"); + Assert.notNull(after, "ExchangeFilterFunction must not be null"); return (request, next) -> { ExchangeFunction nextExchange = exchangeRequest -> after.filter(exchangeRequest, next); return filter(request, nextExchange); @@ -63,7 +63,7 @@ public interface ExchangeFilterFunction { * @return the filtered exchange function */ default ExchangeFunction apply(ExchangeFunction exchange) { - Assert.notNull(exchange, "'exchange' must not be null"); + Assert.notNull(exchange, "ExchangeFunction must not be null"); return request -> this.filter(request, exchange); } @@ -73,10 +73,8 @@ public interface ExchangeFilterFunction { * @param requestProcessor the request processor * @return the filter adaptation of the request processor */ - static ExchangeFilterFunction ofRequestProcessor(Function> requestProcessor) { - - Assert.notNull(requestProcessor, "'requestProcessor' must not be null"); + static ExchangeFilterFunction ofRequestProcessor(Function> requestProcessor) { + Assert.notNull(requestProcessor, "Function must not be null"); return (request, next) -> requestProcessor.apply(request).flatMap(next::exchange); } @@ -86,10 +84,8 @@ public interface ExchangeFilterFunction { * @param responseProcessor the response processor * @return the filter adaptation of the request processor */ - static ExchangeFilterFunction ofResponseProcessor(Function> responseProcessor) { - - Assert.notNull(responseProcessor, "'responseProcessor' must not be null"); + static ExchangeFilterFunction ofResponseProcessor(Function> responseProcessor) { + Assert.notNull(responseProcessor, "Function must not be null"); return (request, next) -> next.exchange(request).flatMap(responseProcessor); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java index 0806c1ba07d..04dcf26a69d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -63,7 +63,6 @@ public abstract class ExchangeFilterFunctions { public static ExchangeFilterFunction basicAuthentication(String username, String password) { Assert.notNull(username, "'username' must not be null"); Assert.notNull(password, "'password' must not be null"); - checkIllegalCharacters(username, password); return basicAuthenticationInternal(r -> Optional.of(new Credentials(username, password))); } @@ -134,8 +133,8 @@ public abstract class ExchangeFilterFunctions { public static ExchangeFilterFunction statusError(Predicate statusPredicate, Function exceptionFunction) { - Assert.notNull(statusPredicate, "'statusPredicate' must not be null"); - Assert.notNull(exceptionFunction, "'exceptionFunction' must not be null"); + Assert.notNull(statusPredicate, "Predicate must not be null"); + Assert.notNull(exceptionFunction, "Function must not be null"); return ExchangeFilterFunction.ofResponseProcessor( clientResponse -> { @@ -168,7 +167,6 @@ public abstract class ExchangeFilterFunctions { public Credentials(String username, String password) { Assert.notNull(username, "'username' must not be null"); Assert.notNull(password, "'password' must not be null"); - this.username = username; this.password = password; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFunction.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFunction.java index 78b8e6c1abe..6a2ca3a54f1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFunction.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -18,8 +18,6 @@ package org.springframework.web.reactive.function.client; import reactor.core.publisher.Mono; -import org.springframework.util.Assert; - /** * Represents a function that exchanges a {@linkplain ClientRequest request} for a (delayed) * {@linkplain ClientResponse}. Can be used as an alternative to {@link WebClient}. @@ -55,7 +53,6 @@ public interface ExchangeFunction { * @see ExchangeFilterFunction#apply(ExchangeFunction) */ default ExchangeFunction filter(ExchangeFilterFunction filter) { - Assert.notNull(filter, "'filter' must not be null"); return filter.apply(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 161f699d1ab..55b2a475013 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 @@ -38,9 +38,9 @@ import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ClientHttpRequest; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyInserter; +import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.util.UriBuilder; import org.springframework.web.util.UriBuilderFactory; -import org.springframework.web.reactive.function.BodyInserters; /** * A non-blocking, reactive client for performing HTTP requests with Reactive diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java index 8540cd893eb..3ed3cd1de02 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java @@ -55,7 +55,7 @@ public class ClientResponseWrapper implements ClientResponse { * @param delegate the response to wrap */ public ClientResponseWrapper(ClientResponse delegate) { - Assert.notNull(delegate, "'delegate' must not be null"); + Assert.notNull(delegate, "Delegate is required"); this.delegate = delegate; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultHandlerStrategiesBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultHandlerStrategiesBuilder.java index 824ad3855ab..3aabec67f29 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultHandlerStrategiesBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultHandlerStrategiesBuilder.java @@ -64,35 +64,34 @@ class DefaultHandlerStrategiesBuilder implements HandlerStrategies.Builder { @Override public HandlerStrategies.Builder codecs(Consumer consumer) { - Assert.notNull(consumer, "'consumer' must not be null"); consumer.accept(this.codecConfigurer); return this; } @Override public HandlerStrategies.Builder viewResolver(ViewResolver viewResolver) { - Assert.notNull(viewResolver, "'viewResolver' must not be null"); + Assert.notNull(viewResolver, "ViewResolver must not be null"); this.viewResolvers.add(viewResolver); return this; } @Override public HandlerStrategies.Builder webFilter(WebFilter filter) { - Assert.notNull(filter, "'filter' must not be null"); + Assert.notNull(filter, "WebFilter must not be null"); this.webFilters.add(filter); return this; } @Override public HandlerStrategies.Builder exceptionHandler(WebExceptionHandler exceptionHandler) { - Assert.notNull(exceptionHandler, "'exceptionHandler' must not be null"); + Assert.notNull(exceptionHandler, "WebExceptionHandler must not be null"); this.exceptionHandlers.add(exceptionHandler); return this; } @Override public HandlerStrategies.Builder localeContextResolver(LocaleContextResolver localeContextResolver) { - Assert.notNull(localeContextResolver, "'localeContextResolver' must not be null"); + Assert.notNull(localeContextResolver, "LocaleContextResolver must not be null"); this.localeContextResolver = localeContextResolver; return this; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java index 55d57685275..5fb6957f15f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java @@ -49,7 +49,7 @@ import org.springframework.web.server.ServerWebExchange; * @author Juergen Hoeller * @since 5.0 */ -class DefaultRenderingResponseBuilder implements RenderingResponse.Builder { +final class DefaultRenderingResponseBuilder implements RenderingResponse.Builder { private final String name; @@ -63,6 +63,7 @@ class DefaultRenderingResponseBuilder implements RenderingResponse.Builder { public DefaultRenderingResponseBuilder(RenderingResponse other) { + Assert.notNull(other, "RenderingResponse must not be null"); this.name = other.name(); this.status = (other instanceof DefaultRenderingResponse ? ((DefaultRenderingResponse) other).statusCode : other.statusCode().value()); @@ -71,6 +72,7 @@ class DefaultRenderingResponseBuilder implements RenderingResponse.Builder { } public DefaultRenderingResponseBuilder(String name) { + Assert.notNull(name, "Name must not be null"); this.name = name; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java index 6ff81115e38..dd6c4aaf0e2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java @@ -43,7 +43,6 @@ import org.springframework.http.codec.multipart.Part; import org.springframework.http.server.PathContainer; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyExtractor; import org.springframework.web.reactive.function.BodyExtractors; @@ -128,7 +127,6 @@ class DefaultServerRequest implements ServerRequest { @Override public T body(BodyExtractor extractor, Map hints) { - Assert.notNull(extractor, "'extractor' must not be null"); return extractor.extract(request(), new BodyExtractor.Context() { @Override @@ -279,6 +277,7 @@ class DefaultServerRequest implements ServerRequest { } } + private final class ServerRequestAdapter implements HttpRequest { @Override @@ -297,5 +296,4 @@ class DefaultServerRequest implements ServerRequest { } } - } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java index 99bd3f47c82..8dbf77609a8 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilder.java @@ -71,13 +71,15 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder { public DefaultServerResponseBuilder(ServerResponse other) { + Assert.notNull(other, "ServerResponse must not be null"); this.statusCode = (other instanceof AbstractServerResponse ? ((AbstractServerResponse) other).statusCode : other.statusCode().value()); this.headers.addAll(other.headers()); } - public DefaultServerResponseBuilder(HttpStatus statusCode) { - this.statusCode = statusCode.value(); + public DefaultServerResponseBuilder(HttpStatus status) { + Assert.notNull(status, "HttpStatus must not be null"); + this.statusCode = status.value(); } public DefaultServerResponseBuilder(int statusCode) { @@ -406,12 +408,10 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder { public List> messageWriters() { return context.messageWriters(); } - @Override public Optional serverRequest() { return Optional.of(exchange.getRequest()); } - @Override public Map hints() { return hints; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/HandlerFilterFunction.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/HandlerFilterFunction.java index 41f5268c981..e2c0ed18ca8 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/HandlerFilterFunction.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/HandlerFilterFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -55,7 +55,7 @@ public interface HandlerFilterFunction andThen(HandlerFilterFunction after) { - Assert.notNull(after, "'after' must not be null"); + Assert.notNull(after, "HandlerFilterFunction must not be null"); return (request, next) -> { HandlerFunction nextHandler = handlerRequest -> after.filter(handlerRequest, next); return filter(request, nextHandler); @@ -68,35 +68,34 @@ public interface HandlerFilterFunction apply(HandlerFunction handler) { - Assert.notNull(handler, "'handler' must not be null"); + Assert.notNull(handler, "HandlerFunction must not be null"); return request -> this.filter(request, handler); } /** - * Adapt the given request processor function to a filter function that only operates on the - * {@code ClientRequest}. + * Adapt the given request processor function to a filter function that only operates + * on the {@code ClientRequest}. * @param requestProcessor the request processor * @return the filter adaptation of the request processor */ static HandlerFilterFunction ofRequestProcessor( Function> requestProcessor) { - Assert.notNull(requestProcessor, "'requestProcessor' must not be null"); + Assert.notNull(requestProcessor, "Function must not be null"); return (request, next) -> requestProcessor.apply(request).flatMap(next::handle); } /** - * Adapt the given response processor function to a filter function that only operates on the - * {@code ClientResponse}. + * Adapt the given response processor function to a filter function that only operates + * on the {@code ClientResponse}. * @param responseProcessor the response processor * @return the filter adaptation of the request processor */ static HandlerFilterFunction ofResponseProcessor( Function> responseProcessor) { - Assert.notNull(responseProcessor, "'responseProcessor' must not be null"); + Assert.notNull(responseProcessor, "Function must not be null"); return (request, next) -> next.handle(request).flatMap(responseProcessor); } - } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java index cea16c4c075..25b79d19802 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java @@ -27,6 +27,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; import org.springframework.http.server.PathContainer; +import org.springframework.util.Assert; import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; import org.springframework.web.util.pattern.PathPattern; @@ -48,6 +49,8 @@ class PathResourceLookupFunction implements Function headersPredicate; public HeadersPredicate(Predicate headersPredicate) { - Assert.notNull(headersPredicate, "'headersPredicate' must not be null"); + Assert.notNull(headersPredicate, "Predicate must not be null"); this.headersPredicate = headersPredicate; } @@ -410,13 +410,15 @@ public abstract class RequestPredicates { private final RequestPredicate right; public AndRequestPredicate(RequestPredicate left, RequestPredicate right) { + Assert.notNull(left, "Left RequestPredicate must not be null"); + Assert.notNull(right, "Right RequestPredicate must not be null"); this.left = left; this.right = right; } @Override public boolean test(ServerRequest t) { - return this.left.test(t) && this.right.test(t); + return (this.left.test(t) && this.right.test(t)); } @Override @@ -437,12 +439,15 @@ public abstract class RequestPredicates { private final RequestPredicate right; public OrRequestPredicate(RequestPredicate left, RequestPredicate right) { + Assert.notNull(left, "Left RequestPredicate must not be null"); + Assert.notNull(right, "Right RequestPredicate must not be null"); this.left = left; this.right = right; } + @Override public boolean test(ServerRequest t) { - return this.left.test(t) || this.right.test(t); + return (this.left.test(t) || this.right.test(t)); } @Override diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java index 7274ac0b18c..049d03ce27f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -83,11 +83,8 @@ public abstract class RouterFunctions { * {@code predicate} evaluates to {@code true} * @see RequestPredicates */ - public static RouterFunction route(RequestPredicate predicate, - HandlerFunction handlerFunction) { - - Assert.notNull(predicate, "'predicate' must not be null"); - Assert.notNull(handlerFunction, "'handlerFunction' must not be null"); + public static RouterFunction route( + RequestPredicate predicate, HandlerFunction handlerFunction) { return new DefaultRouterFunction<>(predicate, handlerFunction); } @@ -115,11 +112,8 @@ public abstract class RouterFunctions { * {@code predicate} evaluates to {@code true} * @see RequestPredicates */ - public static RouterFunction nest(RequestPredicate predicate, - RouterFunction routerFunction) { - - Assert.notNull(predicate, "'predicate' must not be null"); - Assert.notNull(routerFunction, "'routerFunction' must not be null"); + public static RouterFunction nest( + RequestPredicate predicate, RouterFunction routerFunction) { return new DefaultNestedRouterFunction<>(predicate, routerFunction); } @@ -136,8 +130,6 @@ public abstract class RouterFunctions { * @return a router function that routes to resources */ public static RouterFunction resources(String pattern, Resource location) { - Assert.hasLength(pattern, "'pattern' must not be empty"); - Assert.notNull(location, "'location' must not be null"); return resources(new PathResourceLookupFunction(pattern, location)); } @@ -149,7 +141,6 @@ public abstract class RouterFunctions { * @return a router function that routes to resources */ public static RouterFunction resources(Function> lookupFunction) { - Assert.notNull(lookupFunction, "'lookupFunction' must not be null"); return new ResourcesRouterFunction(lookupFunction); } @@ -192,9 +183,6 @@ public abstract class RouterFunctions { * @return an http handler that handles HTTP request using the given router function */ public static HttpHandler toHttpHandler(RouterFunction routerFunction, HandlerStrategies strategies) { - Assert.notNull(routerFunction, "RouterFunction must not be null"); - Assert.notNull(strategies, "HandlerStrategies must not be null"); - WebHandler webHandler = toWebHandler(routerFunction, strategies); return WebHttpHandlerBuilder.webHandler(webHandler) .filters(filters -> filters.addAll(strategies.webFilters())) @@ -396,8 +384,9 @@ public abstract class RouterFunctions { private final HandlerFunction handlerFunction; - public DefaultRouterFunction(RequestPredicate predicate, - HandlerFunction handlerFunction) { + public DefaultRouterFunction(RequestPredicate predicate, HandlerFunction handlerFunction) { + Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(handlerFunction, "HandlerFunction must not be null"); this.predicate = predicate; this.handlerFunction = handlerFunction; } @@ -406,8 +395,7 @@ public abstract class RouterFunctions { public Mono> route(ServerRequest request) { if (this.predicate.test(request)) { if (logger.isDebugEnabled()) { - logger.debug(String.format("Predicate \"%s\" matches against \"%s\"", - this.predicate, request)); + logger.debug(String.format("Predicate \"%s\" matches against \"%s\"", this.predicate, request)); } return Mono.just(this.handlerFunction); } @@ -430,8 +418,9 @@ public abstract class RouterFunctions { private final RouterFunction routerFunction; - public DefaultNestedRouterFunction(RequestPredicate predicate, - RouterFunction routerFunction) { + public DefaultNestedRouterFunction(RequestPredicate predicate, RouterFunction routerFunction) { + Assert.notNull(predicate, "Predicate must not be null"); + Assert.notNull(routerFunction, "RouterFunction must not be null"); this.predicate = predicate; this.routerFunction = routerFunction; } @@ -466,6 +455,7 @@ public abstract class RouterFunctions { private final Function> lookupFunction; public ResourcesRouterFunction(Function> lookupFunction) { + Assert.notNull(lookupFunction, "Function must not be null"); this.lookupFunction = lookupFunction; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java index 50e6f9c1597..2ed5430b040 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerResponse.java @@ -38,7 +38,6 @@ import org.springframework.http.ResponseCookie; import org.springframework.http.codec.HttpMessageWriter; import org.springframework.http.codec.json.Jackson2CodecSupport; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; @@ -91,7 +90,6 @@ public interface ServerResponse { * @return the created builder */ static BodyBuilder from(ServerResponse other) { - Assert.notNull(other, "Other ServerResponse must not be null"); return new DefaultServerResponseBuilder(other); } @@ -101,7 +99,6 @@ public interface ServerResponse { * @return the created builder */ static BodyBuilder status(HttpStatus status) { - Assert.notNull(status, "HttpStatus must not be null"); return new DefaultServerResponseBuilder(status); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/RouterFunctionMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/RouterFunctionMapping.java index cdb3c8b1f04..66a2e2a65fc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/RouterFunctionMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/RouterFunctionMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.lang.Nullable; -import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; @@ -87,7 +86,6 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini *

By default this is set to the {@link ServerCodecConfigurer}'s defaults. */ public void setMessageReaders(List> messageReaders) { - Assert.notNull(messageReaders, "'messageReaders' must not be null"); this.messageReaders = messageReaders; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java index ee3538ee3a7..606ab037d78 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java @@ -201,6 +201,7 @@ public class ServerRequestWrapper implements ServerRequest { return this.delegate.multipartData(); } + /** * Implementation of the {@code Headers} interface that can be subclassed * to adapt the headers in a @@ -211,17 +212,15 @@ public class ServerRequestWrapper implements ServerRequest { private final Headers headers; - /** * Create a new {@code HeadersWrapper} that wraps the given request. * @param headers the headers to wrap */ public HeadersWrapper(Headers headers) { - Assert.notNull(headers, "'headers' must not be null"); + Assert.notNull(headers, "Headers must not be null"); this.headers = headers; } - @Override public List accept() { return this.headers.accept(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerResponseResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerResponseResultHandler.java index fb7b29cc219..02b712ffd4b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerResponseResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerResponseResultHandler.java @@ -53,7 +53,6 @@ public class ServerResponseResultHandler implements HandlerResultHandler, Initia *

By default this is set to {@link ServerCodecConfigurer}'s default writers. */ public void setMessageWriters(List> configurer) { - Assert.notNull(messageWriters, "'messageWriters' must not be null"); this.messageWriters = configurer; } @@ -104,4 +103,5 @@ public class ServerResponseResultHandler implements HandlerResultHandler, Initia } }); } + }