Polishing
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.util.List;
|
||||
@@ -36,7 +37,7 @@ public class HeaderContentTypeResolver implements RequestedContentTypeResolver {
|
||||
try {
|
||||
List<MediaType> mediaTypes = exchange.getRequest().getHeaders().getAccept();
|
||||
MediaType.sortBySpecificityAndQuality(mediaTypes);
|
||||
return !CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST;
|
||||
return (!CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST);
|
||||
}
|
||||
catch (InvalidMediaTypeException ex) {
|
||||
String value = exchange.getRequest().getHeaders().getFirst("Accept");
|
||||
|
||||
@@ -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.
|
||||
@@ -87,11 +87,9 @@ public class RequestedContentTypeResolverBuilder {
|
||||
* of resolvers configured through this builder.
|
||||
*/
|
||||
public RequestedContentTypeResolver build() {
|
||||
|
||||
List<RequestedContentTypeResolver> resolvers =
|
||||
this.candidates.isEmpty() ?
|
||||
Collections.singletonList(new HeaderContentTypeResolver()) :
|
||||
this.candidates.stream().map(Supplier::get).collect(Collectors.toList());
|
||||
List<RequestedContentTypeResolver> resolvers = (!this.candidates.isEmpty() ?
|
||||
this.candidates.stream().map(Supplier::get).collect(Collectors.toList()) :
|
||||
Collections.singletonList(new HeaderContentTypeResolver()));
|
||||
|
||||
return exchange -> {
|
||||
for (RequestedContentTypeResolver resolver : resolvers) {
|
||||
|
||||
@@ -74,7 +74,9 @@ public class PathMatchConfigurer {
|
||||
* @since 5.1
|
||||
*/
|
||||
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate) {
|
||||
this.pathPrefixes = this.pathPrefixes == null ? new LinkedHashMap<>() : this.pathPrefixes;
|
||||
if (this.pathPrefixes == null) {
|
||||
this.pathPrefixes = new LinkedHashMap<>();
|
||||
}
|
||||
this.pathPrefixes.put(prefix, predicate);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,6 @@ class DefaultWebClient implements WebClient {
|
||||
|
||||
private final Map<String, Object> attributes = new LinkedHashMap<>(4);
|
||||
|
||||
|
||||
DefaultRequestBodyUriSpec(HttpMethod httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
@@ -318,7 +317,7 @@ class DefaultWebClient implements WebClient {
|
||||
}
|
||||
|
||||
private ClientRequest.Builder initRequestBuilder() {
|
||||
URI uri = this.uri != null ? this.uri : uriBuilderFactory.expand("");
|
||||
URI uri = (this.uri != null ? this.uri : uriBuilderFactory.expand(""));
|
||||
return ClientRequest.create(this.httpMethod, uri)
|
||||
.headers(headers -> headers.addAll(initHeaders()))
|
||||
.cookies(cookies -> cookies.addAll(initCookies()))
|
||||
|
||||
@@ -228,9 +228,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
||||
if (this.uriBuilderFactory != null) {
|
||||
return this.uriBuilderFactory;
|
||||
}
|
||||
DefaultUriBuilderFactory factory = this.baseUrl != null ?
|
||||
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory();
|
||||
|
||||
DefaultUriBuilderFactory factory = (this.baseUrl != null ?
|
||||
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory());
|
||||
factory.setDefaultUriVariables(this.defaultUriVariables);
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -92,10 +92,8 @@ public abstract class ExchangeFilterFunctions {
|
||||
}
|
||||
|
||||
private static void checkIllegalCharacters(String username, String password) {
|
||||
|
||||
// Basic authentication only supports ISO 8859-1, see
|
||||
// https://stackoverflow.com/questions/702629/utf-8-characters-mangled-in-http-basic-auth-username#703341
|
||||
|
||||
CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
|
||||
if (!encoder.canEncode(username) || !encoder.canEncode(password)) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -113,7 +111,6 @@ public abstract class ExchangeFilterFunctions {
|
||||
}).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a filter that generates an error signal when the given
|
||||
* {@link HttpStatus} predicate matches.
|
||||
@@ -128,10 +125,8 @@ public abstract class ExchangeFilterFunctions {
|
||||
Assert.notNull(exceptionFunction, "Function must not be null");
|
||||
|
||||
return ExchangeFilterFunction.ofResponseProcessor(
|
||||
response -> statusPredicate.test(response.statusCode()) ?
|
||||
Mono.error(exceptionFunction.apply(response)) :
|
||||
Mono.just(response)
|
||||
);
|
||||
response -> (statusPredicate.test(response.statusCode()) ?
|
||||
Mono.error(exceptionFunction.apply(response)) : Mono.just(response)));
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +141,6 @@ public abstract class ExchangeFilterFunctions {
|
||||
|
||||
private final String password;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code Credentials} instance with the given username and password.
|
||||
* @param username the username
|
||||
@@ -159,7 +153,6 @@ public abstract class ExchangeFilterFunctions {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a {@literal Consumer} that stores the given user and password
|
||||
* as a request attribute of type {@code Credentials} that is in turn
|
||||
@@ -174,21 +167,19 @@ public abstract class ExchangeFilterFunctions {
|
||||
public static Consumer<Map<String, Object>> basicAuthenticationCredentials(String user, String password) {
|
||||
Credentials credentials = new Credentials(user, password);
|
||||
checkIllegalCharacters(user, password);
|
||||
return map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials);
|
||||
return (map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Credentials) {
|
||||
Credentials other = (Credentials) o;
|
||||
return this.username.equals(other.username) &&
|
||||
this.password.equals(other.password);
|
||||
if (!(other instanceof Credentials)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Credentials otherCred = (Credentials) other;
|
||||
return (this.username.equals(otherCred.username) && this.password.equals(otherCred.password));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,7 +93,6 @@ public abstract class ExchangeFunctions {
|
||||
@Override
|
||||
public Mono<ClientResponse> exchange(ClientRequest request) {
|
||||
Assert.notNull(request, "ClientRequest must not be null");
|
||||
|
||||
HttpMethod httpMethod = request.method();
|
||||
URI url = request.url();
|
||||
|
||||
@@ -112,7 +111,7 @@ public abstract class ExchangeFunctions {
|
||||
String formatted = request.url().toString();
|
||||
if (this.disableLoggingRequestDetails) {
|
||||
int index = formatted.indexOf("?");
|
||||
formatted = index != -1 ? formatted.substring(0, index) : formatted;
|
||||
formatted = (index != -1 ? formatted.substring(0, index) : formatted);
|
||||
}
|
||||
logger.debug("HTTP " + request.method() + " " + formatted);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||
value = UriUtils.decode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
else {
|
||||
value = StringUtils.hasLength(eq) ? "" : null;
|
||||
value = (StringUtils.hasLength(eq) ? "" : null);
|
||||
}
|
||||
queryParams.add(name, value);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
/**
|
||||
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
|
||||
* <p>If no {@link RouterFunction} is provided at
|
||||
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect
|
||||
* all router functions in the application context, and consult them in
|
||||
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
|
||||
* will detect all router functions in the application context, and consult them in
|
||||
* {@linkplain org.springframework.core.annotation.Order order}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
@@ -114,7 +114,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
||||
SortedRouterFunctionsContainer container = new SortedRouterFunctionsContainer();
|
||||
obtainApplicationContext().getAutowireCapableBeanFactory().autowireBean(container);
|
||||
List<RouterFunction<?>> functions = container.routerFunctions;
|
||||
return CollectionUtils.isEmpty(functions) ? Collections.emptyList() : functions;
|
||||
return (!CollectionUtils.isEmpty(functions) ? functions : Collections.emptyList());
|
||||
}
|
||||
|
||||
private void logRouterFunctions(List<RouterFunction<?>> routerFunctions) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -38,14 +38,14 @@ public abstract class AbstractPrefixVersionStrategy implements VersionStrategy {
|
||||
|
||||
|
||||
protected AbstractPrefixVersionStrategy(String version) {
|
||||
Assert.hasText(version, "'version' must not be empty");
|
||||
Assert.hasText(version, "Version must not be empty");
|
||||
this.prefix = version;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String extractVersion(String requestPath) {
|
||||
return requestPath.startsWith(this.prefix) ? this.prefix : null;
|
||||
return (requestPath.startsWith(this.prefix) ? this.prefix : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,18 +82,15 @@ public class CachingResourceResolver extends AbstractResourceResolver {
|
||||
/**
|
||||
* Configure the supported content codings from the
|
||||
* {@literal "Accept-Encoding"} header for which to cache resource variations.
|
||||
*
|
||||
* <p>The codings configured here are generally expected to match those
|
||||
* configured on {@link EncodedResourceResolver#setContentCodings(List)}.
|
||||
*
|
||||
* <p>By default this property is set to {@literal ["br", "gzip"]} based on
|
||||
* the value of {@link EncodedResourceResolver#DEFAULT_CODINGS}.
|
||||
*
|
||||
* @param codings one or more supported content codings
|
||||
* @since 5.1
|
||||
*/
|
||||
public void setContentCodings(List<String> codings) {
|
||||
Assert.notEmpty(codings, "At least one content coding expected.");
|
||||
Assert.notEmpty(codings, "At least one content coding expected");
|
||||
this.contentCodings.clear();
|
||||
this.contentCodings.addAll(codings);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -281,19 +280,19 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
@Override
|
||||
public int compareTo(ContentChunkInfo other) {
|
||||
return (this.start < other.start ? -1 : (this.start == other.start ? 0 : 1));
|
||||
return Integer.compare(this.start, other.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof ContentChunkInfo) {
|
||||
ContentChunkInfo other = (ContentChunkInfo) obj;
|
||||
return (this.start == other.start && this.end == other.end);
|
||||
if (!(other instanceof ContentChunkInfo)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
ContentChunkInfo otherCci = (ContentChunkInfo) other;
|
||||
return (this.start == otherCci.start && this.end == otherCci.end);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,27 +78,22 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||
* coding that is present in the {@literal "Accept-Encoding"} header for a
|
||||
* given request, and that has a file present with the associated extension,
|
||||
* is used.
|
||||
*
|
||||
* <p><strong>Note:</strong> Each coding must be associated with a file
|
||||
* extension via {@link #registerExtension} or {@link #setExtensions}. Also
|
||||
* customizations to the list of codings here should be matched by
|
||||
* customizations to the same list in {@link CachingResourceResolver} to
|
||||
* ensure encoded variants of a resource are cached under separate keys.
|
||||
*
|
||||
* <p>By default this property is set to {@literal ["br", "gzip"]}.
|
||||
*
|
||||
* @param codings one or more supported content codings
|
||||
* @since 5.1
|
||||
*/
|
||||
public void setContentCodings(List<String> codings) {
|
||||
Assert.notEmpty(codings, "At least one content coding expected.");
|
||||
Assert.notEmpty(codings, "At least one content coding expected");
|
||||
this.contentCodings.clear();
|
||||
this.contentCodings.addAll(codings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a read-only list with the supported content codings.
|
||||
* @since 5.1
|
||||
*/
|
||||
public List<String> getContentCodings() {
|
||||
return Collections.unmodifiableList(this.contentCodings);
|
||||
@@ -110,31 +105,28 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||
* <p>By default this is configured with {@literal ["br" -> ".br"]} and
|
||||
* {@literal ["gzip" -> ".gz"]}.
|
||||
* @param extensions the extensions to use.
|
||||
* @since 5.1
|
||||
* @see #registerExtension(String, String)
|
||||
*/
|
||||
public void setExtensions(Map<String, String> extensions) {
|
||||
extensions.forEach(this::registerExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Java config friendly alternative to {@link #setExtensions(Map)}.
|
||||
* @param coding the content coding
|
||||
* @param extension the associated file extension
|
||||
* @since 5.1
|
||||
*/
|
||||
public void registerExtension(String coding, String extension) {
|
||||
this.extensions.put(coding, extension.startsWith(".") ? extension : "." + extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a read-only map with coding-to-extension mappings.
|
||||
* @since 5.1
|
||||
*/
|
||||
public Map<String, String> getExtensions() {
|
||||
return Collections.unmodifiableMap(this.extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Java config friendly alternative to {@link #setExtensions(Map)}.
|
||||
* @param coding the content coding
|
||||
* @param extension the associated file extension
|
||||
*/
|
||||
public void registerExtension(String coding, String extension) {
|
||||
this.extensions.put(coding, (extension.startsWith(".") ? extension : "." + extension));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Mono<Resource> resolveResourceInternal(@Nullable ServerWebExchange exchange,
|
||||
@@ -174,12 +166,12 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||
private String getAcceptEncoding(ServerWebExchange exchange) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
String header = request.getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
|
||||
return header != null ? header.toLowerCase() : null;
|
||||
return (header != null ? header.toLowerCase() : null);
|
||||
}
|
||||
|
||||
private String getExtension(String coding) {
|
||||
String extension = this.extensions.get(coding);
|
||||
Assert.notNull(extension, "No file extension associated with content coding " + coding);
|
||||
Assert.state(extension != null, () -> "No file extension associated with content coding " + coding);
|
||||
return extension;
|
||||
}
|
||||
|
||||
@@ -202,7 +194,6 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||
|
||||
private final Resource encoded;
|
||||
|
||||
|
||||
EncodedResource(Resource original, String coding, String extension) throws IOException {
|
||||
this.original = original;
|
||||
this.coding = coding;
|
||||
|
||||
@@ -388,8 +388,8 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
Assert.notNull(this.resolverChain, "ResourceResolverChain not initialized.");
|
||||
Assert.notNull(this.transformerChain, "ResourceTransformerChain not initialized.");
|
||||
Assert.state(this.resolverChain != null, "ResourceResolverChain not initialized");
|
||||
Assert.state(this.transformerChain != null, "ResourceTransformerChain not initialized");
|
||||
|
||||
return this.resolverChain.resolveResource(exchange, path, getLocations())
|
||||
.flatMap(resource -> this.transformerChain.transform(exchange, resource));
|
||||
@@ -419,7 +419,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
for (int i = 0; i < path.length(); i++) {
|
||||
char curr = path.charAt(i);
|
||||
try {
|
||||
if ((curr == '/') && (prev == '/')) {
|
||||
if (curr == '/' && prev == '/') {
|
||||
if (sb == null) {
|
||||
sb = new StringBuilder(path.substring(0, i));
|
||||
}
|
||||
@@ -433,7 +433,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
prev = curr;
|
||||
}
|
||||
}
|
||||
return sb != null ? sb.toString() : path;
|
||||
return (sb != null ? sb.toString() : path);
|
||||
}
|
||||
|
||||
private String cleanLeadingSlash(String path) {
|
||||
@@ -446,7 +446,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
if (i == 0 || (i == 1 && slash)) {
|
||||
return path;
|
||||
}
|
||||
return slash ? "/" + path.substring(i) : path.substring(i);
|
||||
return (slash ? "/" + path.substring(i) : path.substring(i));
|
||||
}
|
||||
}
|
||||
return (slash ? "/" : "");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -89,15 +90,15 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractMediaTypeExpression other = (AbstractMediaTypeExpression) obj;
|
||||
return (this.mediaType.equals(other.mediaType) && this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractMediaTypeExpression otherExpr = (AbstractMediaTypeExpression) other;
|
||||
return (this.mediaType.equals(otherExpr.mediaType) && this.isNegated == otherExpr.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,19 +92,16 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof AbstractNameValueExpression) {
|
||||
AbstractNameValueExpression<?> other = (AbstractNameValueExpression<?>) obj;
|
||||
String thisName = isCaseSensitiveName() ? this.name : this.name.toLowerCase();
|
||||
String otherName = isCaseSensitiveName() ? other.name : other.name.toLowerCase();
|
||||
return ((thisName.equalsIgnoreCase(otherName)) &&
|
||||
(this.value != null ? this.value.equals(other.value) : other.value == null) &&
|
||||
this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractNameValueExpression<?> that = (AbstractNameValueExpression<?>) other;
|
||||
return ((isCaseSensitiveName() ? this.name.equals(that.name) : this.name.equalsIgnoreCase(that.name)) &&
|
||||
ObjectUtils.nullSafeEquals(this.value, that.value) && this.isNegated == that.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,4 +131,5 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.web.reactive.result.condition;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A base class for {@link RequestCondition} types providing implementations of
|
||||
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
||||
@@ -28,19 +30,17 @@ import java.util.Iterator;
|
||||
* @param <T> the type of objects that this RequestCondition can be combined
|
||||
* with and compared to
|
||||
*/
|
||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>>
|
||||
implements RequestCondition<T> {
|
||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>> implements RequestCondition<T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj;
|
||||
return getContent().equals(other.getContent());
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -91,7 +91,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
||||
|
||||
@Override
|
||||
protected Collection<?> getContent() {
|
||||
return (isEmpty()) ? Collections.emptyList() : getConditions();
|
||||
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -145,7 +145,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
*/
|
||||
@Override
|
||||
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
||||
return !other.expressions.isEmpty() ? other : this;
|
||||
return (!other.expressions.isEmpty() ? other : this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
}
|
||||
Set<ConsumeMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
||||
result.removeIf(expression -> !expression.match(exchange));
|
||||
return (result.isEmpty()) ? null : new ConsumesRequestCondition(result);
|
||||
return (!result.isEmpty() ? new ConsumesRequestCondition(result) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,14 +56,9 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
* Creates a new instance with the given {@code Stream} of URL patterns.
|
||||
*/
|
||||
public PatternsRequestCondition(List<PathPattern> patterns) {
|
||||
this(toSortedSet(patterns));
|
||||
this(new TreeSet<>(patterns));
|
||||
}
|
||||
|
||||
private static SortedSet<PathPattern> toSortedSet(Collection<PathPattern> patterns) {
|
||||
TreeSet<PathPattern> sorted = new TreeSet<>();
|
||||
sorted.addAll(patterns);
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private PatternsRequestCondition(SortedSet<PathPattern> patterns) {
|
||||
this.patterns = patterns;
|
||||
@@ -127,8 +122,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
return this;
|
||||
}
|
||||
SortedSet<PathPattern> matches = getMatchingPatterns(exchange);
|
||||
return matches.isEmpty() ? null :
|
||||
new PatternsRequestCondition(matches);
|
||||
return (!matches.isEmpty() ? new PatternsRequestCondition(matches) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -192,7 +192,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
}
|
||||
Set<ProduceMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
||||
result.removeIf(expression -> !expression.match(exchange));
|
||||
return (result.isEmpty()) ? null : new ProducesRequestCondition(result, this.contentTypeResolver);
|
||||
return (!result.isEmpty() ? new ProducesRequestCondition(result, this.contentTypeResolver) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
ProduceMediaTypeExpression expr1 = condition1.getExpressionsToCompare().get(index1);
|
||||
ProduceMediaTypeExpression expr2 = condition2.getExpressionsToCompare().get(index2);
|
||||
result = expr1.compareTo(expr2);
|
||||
result = (result != 0) ? result : expr1.getMediaType().compareTo(expr2.getMediaType());
|
||||
result = (result != 0 ? result : expr1.getMediaType().compareTo(expr2.getMediaType()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
* @param providedArgs optional list of argument values to match by type
|
||||
* @return a Mono with a {@link HandlerResult}.
|
||||
*/
|
||||
public Mono<HandlerResult> invoke(ServerWebExchange exchange, BindingContext bindingContext,
|
||||
Object... providedArgs) {
|
||||
public Mono<HandlerResult> invoke(
|
||||
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||
|
||||
return resolveArguments(exchange, bindingContext, providedArgs).flatMap(args -> {
|
||||
Object value;
|
||||
@@ -161,7 +161,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(returnType.getParameterType());
|
||||
boolean asyncVoid = isAsyncVoidReturnType(returnType, adapter);
|
||||
if ((value == null || asyncVoid) && isResponseHandled(args, exchange)) {
|
||||
return asyncVoid ? Mono.from(adapter.toPublisher(value)) : Mono.empty();
|
||||
return (asyncVoid ? Mono.from(adapter.toPublisher(value)) : Mono.empty());
|
||||
}
|
||||
|
||||
HandlerResult result = new HandlerResult(this, value, returnType, bindingContext);
|
||||
@@ -169,8 +169,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
});
|
||||
}
|
||||
|
||||
private Mono<Object[]> resolveArguments(ServerWebExchange exchange, BindingContext bindingContext,
|
||||
Object... providedArgs) {
|
||||
private Mono<Object[]> resolveArguments(
|
||||
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||
|
||||
if (ObjectUtils.isEmpty(getMethodParameters())) {
|
||||
return EMPTY_ARGS;
|
||||
|
||||
@@ -487,8 +487,8 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
public RequestMappingInfo build() {
|
||||
RequestedContentTypeResolver contentTypeResolver = this.options.getContentTypeResolver();
|
||||
|
||||
PathPatternParser parser = this.options.getPatternParser() != null ?
|
||||
this.options.getPatternParser() : new PathPatternParser();
|
||||
PathPatternParser parser = (this.options.getPatternParser() != null ?
|
||||
this.options.getPatternParser() : new PathPatternParser());
|
||||
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
||||
|
||||
return new RequestMappingInfo(this.mappingName, patternsCondition,
|
||||
|
||||
@@ -89,8 +89,8 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
* @param messageReaders readers to convert from the request body
|
||||
* @param adapterRegistry for adapting to other reactive types from Flux and Mono
|
||||
*/
|
||||
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> messageReaders,
|
||||
ReactiveAdapterRegistry adapterRegistry) {
|
||||
protected AbstractMessageReaderArgumentResolver(
|
||||
List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry) {
|
||||
|
||||
super(adapterRegistry);
|
||||
Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required");
|
||||
@@ -121,6 +121,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
*/
|
||||
protected Mono<Object> readBody(MethodParameter bodyParameter, boolean isBodyRequired,
|
||||
BindingContext bindingContext, ServerWebExchange exchange) {
|
||||
|
||||
return this.readBody(bodyParameter, null, isBodyRequired, bindingContext, exchange);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange) {
|
||||
|
||||
ResolvableType bodyType = ResolvableType.forMethodParameter(bodyParam);
|
||||
ResolvableType actualType = actualParam == null ? bodyType : ResolvableType.forMethodParameter(actualParam);
|
||||
ResolvableType actualType = (actualParam != null ? ResolvableType.forMethodParameter(actualParam) : bodyType);
|
||||
Class<?> resolvedType = bodyType.resolve();
|
||||
ReactiveAdapter adapter = (resolvedType != null ? getAdapterRegistry().getAdapter(resolvedType) : null);
|
||||
ResolvableType elementType = (adapter != null ? bodyType.getGeneric() : bodyType);
|
||||
@@ -190,7 +191,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
mono = mono.doOnNext(target ->
|
||||
validate(target, hints, bodyParam, bindingContext, exchange));
|
||||
}
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(mono)) : Mono.from(mono);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(mono)) : Mono.from(mono));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||
* Write a given body to the response with {@link HttpMessageWriter}.
|
||||
* @param body the object to write
|
||||
* @param bodyParameter the {@link MethodParameter} of the body to write
|
||||
* @param actualParameter the actual return type of the method that returned the
|
||||
* value; could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
||||
* @param actualParam the actual return type of the method that returned the value;
|
||||
* could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
||||
* for example
|
||||
* @param exchange the current exchange
|
||||
* @return indicates completion or error
|
||||
@@ -112,11 +112,10 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParameter,
|
||||
@Nullable MethodParameter actualParameter, ServerWebExchange exchange) {
|
||||
@Nullable MethodParameter actualParam, ServerWebExchange exchange) {
|
||||
|
||||
ResolvableType bodyType = ResolvableType.forMethodParameter(bodyParameter);
|
||||
ResolvableType actualType = (actualParameter == null ?
|
||||
bodyType : ResolvableType.forMethodParameter(actualParameter));
|
||||
ResolvableType actualType = (actualParam != null ? ResolvableType.forMethodParameter(actualParam) : bodyType);
|
||||
Class<?> bodyClass = bodyType.resolve();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(bodyClass, body);
|
||||
|
||||
|
||||
@@ -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,9 +40,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*/
|
||||
public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||
|
||||
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers,
|
||||
ReactiveAdapterRegistry registry) {
|
||||
|
||||
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers, ReactiveAdapterRegistry registry) {
|
||||
super(readers, registry);
|
||||
}
|
||||
|
||||
@@ -64,9 +62,9 @@ public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentRes
|
||||
}
|
||||
|
||||
private Object createEntity(@Nullable Object body, Class<?> entityType, ServerHttpRequest request) {
|
||||
return RequestEntity.class.equals(entityType) ?
|
||||
return (RequestEntity.class.equals(entityType) ?
|
||||
new RequestEntity<>(body, request.getHeaders(), request.getMethod(), request.getURI()) :
|
||||
new HttpEntity<>(body, request.getHeaders());
|
||||
new HttpEntity<>(body, request.getHeaders()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -36,7 +36,6 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*/
|
||||
public class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupport {
|
||||
|
||||
|
||||
public PrincipalArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
|
||||
super(adapterRegistry);
|
||||
}
|
||||
@@ -48,12 +47,12 @@ public class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext context,
|
||||
ServerWebExchange exchange) {
|
||||
public Mono<Object> resolveArgument(
|
||||
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
|
||||
|
||||
Mono<Principal> principal = exchange.getPrincipal();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(principal)) : Mono.from(principal);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(principal)) : Mono.from(principal));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.springframework.web.server.ServerWebInputException;
|
||||
*/
|
||||
public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||
|
||||
|
||||
public RequestPartMethodArgumentResolver(List<HttpMessageReader<?>> readers,
|
||||
ReactiveAdapterRegistry registry) {
|
||||
|
||||
@@ -78,9 +77,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
||||
.flatMapMany(map -> {
|
||||
List<Part> list = map.get(name);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return isRequired ?
|
||||
Flux.error(getMissingPartException(name, parameter)) :
|
||||
Flux.empty();
|
||||
return (isRequired ? Flux.error(getMissingPartException(name, parameter)) : Flux.empty());
|
||||
}
|
||||
return Flux.fromIterable(list);
|
||||
});
|
||||
@@ -105,7 +102,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
||||
// Mono<Part> or Flux<Part>
|
||||
MethodParameter elementType = parameter.nested();
|
||||
if (Part.class.isAssignableFrom(elementType.getNestedParameterType())) {
|
||||
parts = adapter.isMultiValue() ? parts : parts.take(1);
|
||||
parts = (adapter.isMultiValue() ? parts : parts.take(1));
|
||||
return Mono.just(adapter.fromPublisher(parts));
|
||||
}
|
||||
// We have to decode the content for each part, one at a time
|
||||
|
||||
@@ -102,12 +102,12 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso
|
||||
else if (TimeZone.class == paramType) {
|
||||
LocaleContext localeContext = exchange.getLocaleContext();
|
||||
TimeZone timeZone = getTimeZone(localeContext);
|
||||
return timeZone != null ? timeZone : TimeZone.getDefault();
|
||||
return (timeZone != null ? timeZone : TimeZone.getDefault());
|
||||
}
|
||||
else if (ZoneId.class == paramType) {
|
||||
LocaleContext localeContext = exchange.getLocaleContext();
|
||||
TimeZone timeZone = getTimeZone(localeContext);
|
||||
return timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault();
|
||||
return (timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault());
|
||||
}
|
||||
else if (UriBuilder.class == paramType || UriComponentsBuilder.class == paramType) {
|
||||
URI uri = exchange.getRequest().getURI();
|
||||
|
||||
@@ -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 class WebSessionArgumentResolver extends HandlerMethodArgumentResolverSup
|
||||
|
||||
Mono<WebSession> session = exchange.getSession();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(session)) : Mono.from(session);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(session)) : Mono.from(session));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -23,8 +23,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -45,9 +43,6 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
*/
|
||||
public class HttpMessageWriterView implements View {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(HttpMessageWriter.class);
|
||||
|
||||
|
||||
private final HttpMessageWriter<?> writer;
|
||||
|
||||
private final Set<String> modelKeys = new HashSet<>(4);
|
||||
@@ -66,7 +61,7 @@ public class HttpMessageWriterView implements View {
|
||||
* Constructor with a fully initialized {@link HttpMessageWriter}.
|
||||
*/
|
||||
public HttpMessageWriterView(HttpMessageWriter<?> writer) {
|
||||
Assert.notNull(writer, "'writer' is required.");
|
||||
Assert.notNull(writer, "HttpMessageWriter is required");
|
||||
this.writer = writer;
|
||||
this.canWriteMap = writer.canWrite(ResolvableType.forClass(Map.class), null);
|
||||
}
|
||||
@@ -118,12 +113,11 @@ public class HttpMessageWriterView implements View {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType,
|
||||
ServerWebExchange exchange) {
|
||||
public Mono<Void> render(
|
||||
@Nullable Map<String, ?> model, @Nullable MediaType contentType, ServerWebExchange exchange) {
|
||||
|
||||
Object value = getObjectToRender(model);
|
||||
return (value != null) ?
|
||||
write(value, contentType, exchange) : exchange.getResponse().setComplete();
|
||||
return (value != null ? write(value, contentType, exchange) : exchange.getResponse().setComplete());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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.
|
||||
@@ -196,7 +196,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
|
||||
}
|
||||
if (this.resourceLoaderPaths == null) {
|
||||
String resourceLoaderPath = viewConfig.getResourceLoaderPath();
|
||||
setResourceLoaderPath(resourceLoaderPath == null ? DEFAULT_RESOURCE_LOADER_PATH : resourceLoaderPath);
|
||||
setResourceLoaderPath(resourceLoaderPath != null ? resourceLoaderPath : DEFAULT_RESOURCE_LOADER_PATH);
|
||||
}
|
||||
if (this.sharedEngine == null && viewConfig.isSharedEngine() != null) {
|
||||
this.sharedEngine = viewConfig.isSharedEngine();
|
||||
|
||||
@@ -80,8 +80,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
||||
* @param handshakeInfo the handshake info
|
||||
* @param bufferFactory the DataBuffer factor for the current connection
|
||||
*/
|
||||
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo,
|
||||
DataBufferFactory bufferFactory) {
|
||||
public AbstractListenerWebSocketSession(
|
||||
T delegate, String id, HandshakeInfo handshakeInfo, DataBufferFactory bufferFactory) {
|
||||
|
||||
this(delegate, id, handshakeInfo, bufferFactory, null);
|
||||
}
|
||||
@@ -106,9 +106,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
||||
|
||||
@Override
|
||||
public Flux<WebSocketMessage> receive() {
|
||||
return canSuspendReceiving() ?
|
||||
Flux.from(this.receivePublisher) :
|
||||
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE);
|
||||
return (canSuspendReceiving() ? Flux.from(this.receivePublisher) :
|
||||
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.springframework.web.reactive.socket.adapter.JettyWebSocketSession;
|
||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
|
||||
/**
|
||||
* A {@link RequestUpgradeStrategy} for use with Jetty.
|
||||
*
|
||||
@@ -95,9 +94,9 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
|
||||
if (!isRunning() && servletContext != null) {
|
||||
this.running = true;
|
||||
try {
|
||||
this.factory = this.webSocketPolicy != null ?
|
||||
this.factory = (this.webSocketPolicy != null ?
|
||||
new WebSocketServerFactory(servletContext, this.webSocketPolicy) :
|
||||
new WebSocketServerFactory(servletContext);
|
||||
new WebSocketServerFactory(servletContext));
|
||||
this.factory.setCreator((request, response) -> {
|
||||
WebSocketHandlerContainer container = adapterHolder.get();
|
||||
String protocol = container.getProtocol();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class HeadersRequestConditionTests {
|
||||
public void headerEquals() {
|
||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("foo"));
|
||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("FOO"));
|
||||
assertFalse(new HeadersRequestCondition("foo").equals(new HeadersRequestCondition("bar")));
|
||||
assertNotEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("bar"));
|
||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("foo=bar"));
|
||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("FOO=bar"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user