Polishing
This commit is contained in:
@@ -171,7 +171,6 @@ public final class MultipartBodyBuilder {
|
||||
* @param elementClass the type of elements contained in the publisher
|
||||
* @return builder that allows for further customization of part headers
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, P extends Publisher<T>> PartBuilder asyncPart(String name, P publisher, Class<T> elementClass) {
|
||||
Assert.hasLength(name, "'name' must not be empty");
|
||||
Assert.notNull(publisher, "'publisher' must not be null");
|
||||
|
||||
@@ -53,21 +53,6 @@ public class JettyClientHttpConnector implements ClientHttpConnector {
|
||||
this(new HttpClient());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an {@link JettyResourceFactory} that will manage shared resources.
|
||||
* @param resourceFactory the {@link JettyResourceFactory} to use
|
||||
* @param customizer the lambda used to customize the {@link HttpClient}
|
||||
* @deprecated as of 5.2, in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettyClientHttpConnector(
|
||||
JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
|
||||
this(new HttpClient(), resourceFactory);
|
||||
if (customizer != null) {
|
||||
customizer.accept(this.httpClient);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an initialized {@link HttpClient}.
|
||||
*/
|
||||
@@ -82,8 +67,7 @@ public class JettyClientHttpConnector implements ClientHttpConnector {
|
||||
* @param resourceFactory the {@link JettyResourceFactory} to use
|
||||
* @since 5.2
|
||||
*/
|
||||
public JettyClientHttpConnector(HttpClient httpClient,
|
||||
@Nullable JettyResourceFactory resourceFactory) {
|
||||
public JettyClientHttpConnector(HttpClient httpClient, @Nullable JettyResourceFactory resourceFactory) {
|
||||
Assert.notNull(httpClient, "HttpClient is required");
|
||||
if (resourceFactory != null) {
|
||||
httpClient.setExecutor(resourceFactory.getExecutor());
|
||||
@@ -93,6 +77,20 @@ public class JettyClientHttpConnector implements ClientHttpConnector {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an {@link JettyResourceFactory} that will manage shared resources.
|
||||
* @param resourceFactory the {@link JettyResourceFactory} to use
|
||||
* @param customizer the lambda used to customize the {@link HttpClient}
|
||||
* @deprecated as of 5.2, in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettyClientHttpConnector(JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
|
||||
this(new HttpClient(), resourceFactory);
|
||||
if (customizer != null) {
|
||||
customizer.accept(this.httpClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setBufferFactory(DataBufferFactory bufferFactory) {
|
||||
this.bufferFactory = bufferFactory;
|
||||
|
||||
@@ -130,8 +130,7 @@ public abstract class HttpAccessor {
|
||||
}
|
||||
|
||||
private void initialize(ClientHttpRequest request) {
|
||||
this.clientHttpRequestInitializers.forEach(
|
||||
initializer -> initializer.initialize(request));
|
||||
this.clientHttpRequestInitializers.forEach(initializer -> initializer.initialize(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,8 +51,10 @@ public class Jackson2CborDecoder extends AbstractJackson2Decoder {
|
||||
Assert.isAssignable(CBORFactory.class, mapper.getFactory().getClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
throw new UnsupportedOperationException("Does not support stream decoding yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,10 @@ public class Jackson2CborEncoder extends AbstractJackson2Encoder {
|
||||
Assert.isAssignable(CBORFactory.class, mapper.getFactory().getClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Flux<DataBuffer> encode(Publisher<?> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
|
||||
throw new UnsupportedOperationException("Does not support stream encoding yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -203,22 +203,18 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
* Add {@link MediaType} objects to be supported by this converter.
|
||||
* <p>The supplied {@code MediaType} objects will be appended to the list
|
||||
* of {@linkplain #getSupportedMediaTypes() supported MediaType objects}.
|
||||
* @param supportedMediaTypes a var-args list of {@code MediaType} objects
|
||||
* to add
|
||||
* @param supportedMediaTypes a var-args list of {@code MediaType} objects to add
|
||||
* @since 5.2
|
||||
* @see #setSupportedMediaTypes(List)
|
||||
*/
|
||||
public void addSupportedMediaTypes(MediaType... supportedMediaTypes) {
|
||||
Assert.notNull(supportedMediaTypes, "'supportedMediaTypes' must not be null");
|
||||
Assert.noNullElements(supportedMediaTypes, "'supportedMediaTypes' must not contain null elements");
|
||||
for (MediaType mediaType : supportedMediaTypes) {
|
||||
this.supportedMediaTypes.add(mediaType);
|
||||
}
|
||||
Collections.addAll(this.supportedMediaTypes, supportedMediaTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see #setSupportedMediaTypes(List)
|
||||
* @see #addSupportedMediaTypes(MediaType...)
|
||||
*/
|
||||
|
||||
@@ -148,18 +148,15 @@ public interface PathContainer {
|
||||
*/
|
||||
public final static Options MESSAGE_ROUTE = Options.create('.', false);
|
||||
|
||||
|
||||
private final char separator;
|
||||
|
||||
private final boolean decodeAndParseSegments;
|
||||
|
||||
|
||||
private Options(char separator, boolean decodeAndParseSegments) {
|
||||
this.separator = separator;
|
||||
this.decodeAndParseSegments = decodeAndParseSegments;
|
||||
}
|
||||
|
||||
|
||||
public char separator() {
|
||||
return this.separator;
|
||||
}
|
||||
@@ -168,7 +165,6 @@ public interface PathContainer {
|
||||
return this.decodeAndParseSegments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an {@link Options} instance with the given settings.
|
||||
* @param separator the separator for parsing the path into segments;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.filter.reactive;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -38,10 +38,14 @@ import org.springframework.web.server.WebHandler;
|
||||
*/
|
||||
public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
|
||||
|
||||
|
||||
private final List<WebExceptionHandler> exceptionHandlers;
|
||||
|
||||
|
||||
/**
|
||||
* Create an {@code ExceptionHandlingWebHandler} for the given delegate.
|
||||
* @param delegate the WebHandler delegate
|
||||
* @param handlers the WebExceptionHandlers to apply
|
||||
*/
|
||||
public ExceptionHandlingWebHandler(WebHandler delegate, List<WebExceptionHandler> handlers) {
|
||||
super(delegate);
|
||||
List<WebExceptionHandler> handlersToUse = new ArrayList<>();
|
||||
@@ -61,7 +65,6 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange) {
|
||||
|
||||
Mono<Void> completion;
|
||||
try {
|
||||
completion = super.handle(exchange);
|
||||
@@ -73,7 +76,6 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
|
||||
for (WebExceptionHandler handler : this.exceptionHandlers) {
|
||||
completion = completion.onErrorResume(ex -> handler.handle(exchange, ex));
|
||||
}
|
||||
|
||||
return completion;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -33,12 +33,19 @@ public class WebHandlerDecorator implements WebHandler {
|
||||
private final WebHandler delegate;
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@code WebHandlerDecorator} for the given delegate.
|
||||
* @param delegate the WebHandler delegate
|
||||
*/
|
||||
public WebHandlerDecorator(WebHandler delegate) {
|
||||
Assert.notNull(delegate, "'delegate' must not be null");
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the wrapped delegate.
|
||||
*/
|
||||
public WebHandler getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public interface UriBuilder {
|
||||
* only (i.e. {@code ?foo} instead of {@code ?foo=bar}.
|
||||
* @param name the query parameter name
|
||||
* @param values the query parameter values
|
||||
* @since 5.2.0
|
||||
* @since 5.2
|
||||
* @see #queryParam(String, Object...)
|
||||
*/
|
||||
UriBuilder queryParam(String name, @Nullable Collection<?> values);
|
||||
@@ -161,7 +161,7 @@ public interface UriBuilder {
|
||||
* the same parameter. If no values are given, the query parameter is removed.
|
||||
* @param name the query parameter name
|
||||
* @param values the query parameter values
|
||||
* @since 5.2.0
|
||||
* @since 5.2
|
||||
* @see #replaceQueryParam(String, Object...)
|
||||
*/
|
||||
UriBuilder replaceQueryParam(String name, @Nullable Collection<?> values);
|
||||
|
||||
@@ -725,7 +725,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
* @param name the query parameter name
|
||||
* @param values the query parameter values
|
||||
* @return this UriComponentsBuilder
|
||||
* @since 5.2.0
|
||||
* @since 5.2
|
||||
* @see #queryParam(String, Object...)
|
||||
*/
|
||||
@Override
|
||||
@@ -773,7 +773,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
* @param values the query parameter values
|
||||
* @return this UriComponentsBuilder
|
||||
* @see #replaceQueryParam(String, Object...)
|
||||
* @since 5.2.0
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
public UriComponentsBuilder replaceQueryParam(String name, @Nullable Collection<?> values) {
|
||||
|
||||
@@ -176,7 +176,6 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
return this.patternString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the pattern string contains pattern syntax that would require
|
||||
* use of {@link #matches(PathContainer)}, or if it is a regular String that
|
||||
@@ -184,7 +183,7 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
* @since 5.2
|
||||
*/
|
||||
public boolean hasPatternSyntax() {
|
||||
return this.score > 0 || this.patternString.indexOf('?') != -1;
|
||||
return (this.score > 0 || this.patternString.indexOf('?') != -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,9 +217,9 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
@Nullable
|
||||
public PathMatchInfo matchAndExtract(PathContainer pathContainer) {
|
||||
if (this.head == null) {
|
||||
return hasLength(pathContainer) &&
|
||||
!(this.matchOptionalTrailingSeparator && pathContainerIsJustSeparator(pathContainer))
|
||||
? null : PathMatchInfo.EMPTY;
|
||||
return (hasLength(pathContainer) &&
|
||||
!(this.matchOptionalTrailingSeparator && pathContainerIsJustSeparator(pathContainer)) ?
|
||||
null : PathMatchInfo.EMPTY);
|
||||
}
|
||||
else if (!hasLength(pathContainer)) {
|
||||
if (this.head instanceof WildcardTheRestPathElement || this.head instanceof CaptureTheRestPathElement) {
|
||||
@@ -442,6 +441,7 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
return this.patternString;
|
||||
}
|
||||
|
||||
|
||||
int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
@@ -537,30 +537,25 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
pathContainer.value().charAt(0) == getSeparator();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Holder for URI variables and path parameters (matrix variables) extracted
|
||||
* based on the pattern for a given matched path.
|
||||
*/
|
||||
public static class PathMatchInfo {
|
||||
|
||||
private static final PathMatchInfo EMPTY =
|
||||
new PathMatchInfo(Collections.emptyMap(), Collections.emptyMap());
|
||||
|
||||
private static final PathMatchInfo EMPTY = new PathMatchInfo(Collections.emptyMap(), Collections.emptyMap());
|
||||
|
||||
private final Map<String, String> uriVariables;
|
||||
|
||||
private final Map<String, MultiValueMap<String, String>> matrixVariables;
|
||||
|
||||
|
||||
PathMatchInfo(Map<String, String> uriVars,
|
||||
@Nullable Map<String, MultiValueMap<String, String>> matrixVars) {
|
||||
|
||||
PathMatchInfo(Map<String, String> uriVars, @Nullable Map<String, MultiValueMap<String, String>> matrixVars) {
|
||||
this.uriVariables = Collections.unmodifiableMap(uriVars);
|
||||
this.matrixVariables = matrixVars != null ?
|
||||
Collections.unmodifiableMap(matrixVars) : Collections.emptyMap();
|
||||
this.matrixVariables = (matrixVars != null ?
|
||||
Collections.unmodifiableMap(matrixVars) : Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the extracted URI variables.
|
||||
*/
|
||||
@@ -717,4 +712,5 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user