Polishing
This commit is contained in:
parent
9a36027ae1
commit
c4622dbebc
|
@ -430,7 +430,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass);
|
||||
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -144,7 +144,7 @@ public class ObjectError extends DefaultMessageSourceResolvable {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 29 + getObjectName().hashCode();
|
||||
return (29 * super.hashCode() + getObjectName().hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -591,7 +591,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector);
|
||||
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.
|
||||
|
@ -110,9 +110,8 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
|||
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
|
||||
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
|
||||
if (resolver == null) {
|
||||
throw new IllegalStateException(
|
||||
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
|
||||
" supportsParameter should be called first.");
|
||||
throw new IllegalArgumentException("Unsupported parameter type [" +
|
||||
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
|
||||
}
|
||||
return resolver.resolveArgument(parameter, message);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
|
@ -178,7 +178,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 31 + this.resourceBasePath.hashCode();
|
||||
return (31 * super.hashCode() + this.resourceBasePath.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
@ -447,6 +447,7 @@ public enum HttpStatus {
|
|||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is1xxInformational() {
|
||||
|
@ -457,6 +458,7 @@ public enum HttpStatus {
|
|||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is2xxSuccessful() {
|
||||
|
@ -467,6 +469,7 @@ public enum HttpStatus {
|
|||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is3xxRedirection() {
|
||||
|
@ -477,6 +480,7 @@ public enum HttpStatus {
|
|||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is4xxClientError() {
|
||||
|
@ -487,6 +491,7 @@ public enum HttpStatus {
|
|||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is5xxServerError() {
|
||||
|
|
|
@ -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.
|
||||
|
@ -169,7 +169,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.status));
|
||||
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.status));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -109,7 +109,7 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
|
|||
@Override
|
||||
@Nullable
|
||||
public HttpStatus getStatusCode() {
|
||||
return this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null;
|
||||
return (this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
@ -19,7 +19,6 @@ package org.springframework.http.server.reactive;
|
|||
import java.nio.file.Path;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.cookie.Cookie;
|
||||
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
@ -62,14 +61,9 @@ class ReactorServerHttpResponse extends AbstractServerHttpResponse implements Ze
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public HttpStatus getStatusCode() {
|
||||
HttpStatus httpStatus = super.getStatusCode();
|
||||
if (httpStatus == null) {
|
||||
HttpResponseStatus status = this.response.status();
|
||||
httpStatus = status != null ? HttpStatus.resolve(status.code()) : null;
|
||||
}
|
||||
return httpStatus;
|
||||
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.status().code()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -100,7 +100,7 @@ class ServletServerHttpResponse extends AbstractListenerServerHttpResponse {
|
|||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
HttpStatus httpStatus = super.getStatusCode();
|
||||
return httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.getStatus());
|
||||
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.getStatus()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.
|
||||
|
@ -69,8 +69,7 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
|
|||
}
|
||||
|
||||
private static HttpHeaders createHeaders(HttpServerExchange exchange) {
|
||||
UndertowHeadersAdapter headersMap =
|
||||
new UndertowHeadersAdapter(exchange.getResponseHeaders());
|
||||
UndertowHeadersAdapter headersMap = new UndertowHeadersAdapter(exchange.getResponseHeaders());
|
||||
return new HttpHeaders(headersMap);
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,7 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
|
|||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
HttpStatus httpStatus = super.getStatusCode();
|
||||
return httpStatus != null ? httpStatus : HttpStatus.resolve(this.exchange.getStatusCode());
|
||||
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.exchange.getStatusCode()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -119,9 +119,8 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
|||
|
||||
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
|
||||
if (resolver == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
|
||||
" supportsParameter should be called first.");
|
||||
throw new IllegalArgumentException("Unsupported parameter type [" +
|
||||
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
|
||||
}
|
||||
return resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -40,7 +40,7 @@ public class HandlerMethodArgumentResolverCompositeTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
this.resolverComposite = new HandlerMethodArgumentResolverComposite();
|
||||
|
||||
Method method = getClass().getDeclaredMethod("handle", Integer.class, String.class);
|
||||
|
@ -50,7 +50,7 @@ public class HandlerMethodArgumentResolverCompositeTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
public void supportsParameter() throws Exception {
|
||||
this.resolverComposite.addResolver(new StubArgumentResolver(Integer.class));
|
||||
|
||||
assertTrue(this.resolverComposite.supportsParameter(paramInt));
|
||||
|
|
|
@ -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.
|
||||
|
@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
/**
|
||||
* Test fixture with {@link HandlerMethodReturnValueHandlerComposite}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -47,8 +48,7 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
public void setup() throws Exception {
|
||||
this.integerType = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1);
|
||||
this.stringType = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1);
|
||||
|
||||
|
@ -61,6 +61,7 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
|||
mavContainer = new ModelAndViewContainer();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsReturnType() throws Exception {
|
||||
assertTrue(this.handlers.supportsReturnType(this.integerType));
|
||||
|
@ -84,9 +85,8 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
|||
verifyNoMoreInteractions(anotherIntegerHandler);
|
||||
}
|
||||
|
||||
@Test // SPR-13083
|
||||
@Test // SPR-13083
|
||||
public void handleReturnValueWithAsyncHandler() throws Exception {
|
||||
|
||||
Promise<Integer> promise = new Promise<>();
|
||||
MethodParameter promiseType = new MethodParameter(getClass().getDeclaredMethod("handlePromise"), -1);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -129,13 +129,11 @@ final class DefaultClientResponseBuilder implements ClientResponse.Builder {
|
|||
|
||||
@Override
|
||||
public ClientResponse build() {
|
||||
|
||||
ClientHttpResponse httpResponse =
|
||||
new BuiltClientHttpResponse(this.statusCode, this.headers, this.cookies, this.body);
|
||||
|
||||
// When building ClientResponse manually, the ClientRequest.logPrefix() has to be passed,
|
||||
// e.g. via ClientResponse.Builder, but this (builder) is not used currently.
|
||||
|
||||
return new DefaultClientResponse(httpResponse, this.strategies, "");
|
||||
}
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ class DefaultWebClient implements WebClient {
|
|||
private static IntPredicate toIntPredicate(Predicate<HttpStatus> predicate) {
|
||||
return value -> {
|
||||
HttpStatus status = HttpStatus.resolve(value);
|
||||
return (status != null) && predicate.test(status);
|
||||
return (status != null && predicate.test(status));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,6 @@ class DefaultWebClient implements WebClient {
|
|||
}
|
||||
this.statusHandlers.add(new StatusHandler(statusCodePredicate,
|
||||
(clientResponse, request) -> exceptionFunction.apply(clientResponse)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -539,8 +538,6 @@ class DefaultWebClient implements WebClient {
|
|||
public StatusHandler(IntPredicate predicate,
|
||||
BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction) {
|
||||
|
||||
Assert.notNull(predicate, "Predicate must not be null");
|
||||
Assert.notNull(exceptionFunction, "Function must not be null");
|
||||
this.predicate = predicate;
|
||||
this.exceptionFunction = exceptionFunction;
|
||||
}
|
||||
|
@ -552,8 +549,6 @@ class DefaultWebClient implements WebClient {
|
|||
public Mono<? extends Throwable> apply(ClientResponse response, HttpRequest request) {
|
||||
return this.exceptionFunction.apply(response, request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -583,6 +583,7 @@ public interface WebClient {
|
|||
RequestHeadersSpec<?> syncBody(Object body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contract for specifying response operations following the exchange.
|
||||
*/
|
||||
|
@ -666,24 +667,22 @@ public interface WebClient {
|
|||
* status code is 4xx or 5xx
|
||||
*/
|
||||
<T> Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contract for specifying request headers and URI for a request.
|
||||
*
|
||||
* @param <S> a self reference to the spec type
|
||||
*/
|
||||
interface RequestHeadersUriSpec<S extends RequestHeadersSpec<S>>
|
||||
extends UriSpec<S>, RequestHeadersSpec<S> {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contract for specifying request headers, body and URI for a request.
|
||||
*/
|
||||
interface RequestBodyUriSpec extends RequestBodySpec, RequestHeadersUriSpec<RequestBodySpec> {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue