Skip to content

Commit c4622db

Browse files
committed
Polishing
1 parent 9a36027 commit c4622db

File tree

17 files changed

+40
-52
lines changed

17 files changed

+40
-52
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public boolean equals(Object other) {
430430

431431
@Override
432432
public int hashCode() {
433-
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass);
433+
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass));
434434
}
435435

436436

spring-context/src/main/java/org/springframework/validation/ObjectError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -144,7 +144,7 @@ public boolean equals(@Nullable Object other) {
144144

145145
@Override
146146
public int hashCode() {
147-
return super.hashCode() * 29 + getObjectName().hashCode();
147+
return (29 * super.hashCode() + getObjectName().hashCode());
148148
}
149149

150150
@Override

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public boolean equals(Object other) {
591591

592592
@Override
593593
public int hashCode() {
594-
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector);
594+
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
595595
}
596596

597597
@Override

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -110,9 +110,8 @@ public boolean supportsParameter(MethodParameter parameter) {
110110
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
111111
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
112112
if (resolver == null) {
113-
throw new IllegalStateException(
114-
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
115-
" supportsParameter should be called first.");
113+
throw new IllegalArgumentException("Unsupported parameter type [" +
114+
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
116115
}
117116
return resolver.resolveArgument(parameter, message);
118117
}

spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -178,7 +178,7 @@ public boolean equals(@Nullable Object other) {
178178
*/
179179
@Override
180180
public int hashCode() {
181-
return super.hashCode() * 31 + this.resourceBasePath.hashCode();
181+
return (31 * super.hashCode() + this.resourceBasePath.hashCode());
182182
}
183183

184184
/**

spring-web/src/main/java/org/springframework/http/HttpStatus.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -447,6 +447,7 @@ public Series series() {
447447
* Whether this status code is in the HTTP series
448448
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
449449
* This is a shortcut for checking the value of {@link #series()}.
450+
* @since 4.0
450451
* @see #series()
451452
*/
452453
public boolean is1xxInformational() {
@@ -457,6 +458,7 @@ public boolean is1xxInformational() {
457458
* Whether this status code is in the HTTP series
458459
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
459460
* This is a shortcut for checking the value of {@link #series()}.
461+
* @since 4.0
460462
* @see #series()
461463
*/
462464
public boolean is2xxSuccessful() {
@@ -467,6 +469,7 @@ public boolean is2xxSuccessful() {
467469
* Whether this status code is in the HTTP series
468470
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
469471
* This is a shortcut for checking the value of {@link #series()}.
472+
* @since 4.0
470473
* @see #series()
471474
*/
472475
public boolean is3xxRedirection() {
@@ -477,6 +480,7 @@ public boolean is3xxRedirection() {
477480
* Whether this status code is in the HTTP series
478481
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
479482
* This is a shortcut for checking the value of {@link #series()}.
483+
* @since 4.0
480484
* @see #series()
481485
*/
482486
public boolean is4xxClientError() {
@@ -487,6 +491,7 @@ public boolean is4xxClientError() {
487491
* Whether this status code is in the HTTP series
488492
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
489493
* This is a shortcut for checking the value of {@link #series()}.
494+
* @since 4.0
490495
* @see #series()
491496
*/
492497
public boolean is5xxServerError() {

spring-web/src/main/java/org/springframework/http/ResponseEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -169,7 +169,7 @@ public boolean equals(@Nullable Object other) {
169169

170170
@Override
171171
public int hashCode() {
172-
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.status));
172+
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.status));
173173
}
174174

175175
@Override

spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public boolean setStatusCode(@Nullable HttpStatus status) {
109109
@Override
110110
@Nullable
111111
public HttpStatus getStatusCode() {
112-
return this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null;
112+
return (this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null);
113113
}
114114

115115
/**

spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.nio.file.Path;
2020

2121
import io.netty.buffer.ByteBuf;
22-
import io.netty.handler.codec.http.HttpResponseStatus;
2322
import io.netty.handler.codec.http.cookie.Cookie;
2423
import io.netty.handler.codec.http.cookie.DefaultCookie;
2524
import org.reactivestreams.Publisher;
@@ -62,14 +61,9 @@ public <T> T getNativeResponse() {
6261
}
6362

6463
@Override
65-
@SuppressWarnings("ConstantConditions")
6664
public HttpStatus getStatusCode() {
6765
HttpStatus httpStatus = super.getStatusCode();
68-
if (httpStatus == null) {
69-
HttpResponseStatus status = this.response.status();
70-
httpStatus = status != null ? HttpStatus.resolve(status.code()) : null;
71-
}
72-
return httpStatus;
66+
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.status().code()));
7367
}
7468

7569

spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public <T> T getNativeResponse() {
100100
@Override
101101
public HttpStatus getStatusCode() {
102102
HttpStatus httpStatus = super.getStatusCode();
103-
return httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.getStatus());
103+
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.response.getStatus()));
104104
}
105105

106106
@Override

spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,8 +69,7 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
6969
}
7070

7171
private static HttpHeaders createHeaders(HttpServerExchange exchange) {
72-
UndertowHeadersAdapter headersMap =
73-
new UndertowHeadersAdapter(exchange.getResponseHeaders());
72+
UndertowHeadersAdapter headersMap = new UndertowHeadersAdapter(exchange.getResponseHeaders());
7473
return new HttpHeaders(headersMap);
7574
}
7675

@@ -84,7 +83,7 @@ public <T> T getNativeResponse() {
8483
@Override
8584
public HttpStatus getStatusCode() {
8685
HttpStatus httpStatus = super.getStatusCode();
87-
return httpStatus != null ? httpStatus : HttpStatus.resolve(this.exchange.getStatusCode());
86+
return (httpStatus != null ? httpStatus : HttpStatus.resolve(this.exchange.getStatusCode()));
8887
}
8988

9089

spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -119,9 +119,8 @@ public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewC
119119

120120
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
121121
if (resolver == null) {
122-
throw new IllegalArgumentException(
123-
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
124-
" supportsParameter should be called first.");
122+
throw new IllegalArgumentException("Unsupported parameter type [" +
123+
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
125124
}
126125
return resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
127126
}

spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodArgumentResolverCompositeTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public class HandlerMethodArgumentResolverCompositeTests {
4040

4141

4242
@Before
43-
public void setUp() throws Exception {
43+
public void setup() throws Exception {
4444
this.resolverComposite = new HandlerMethodArgumentResolverComposite();
4545

4646
Method method = getClass().getDeclaredMethod("handle", Integer.class, String.class);
@@ -50,7 +50,7 @@ public void setUp() throws Exception {
5050

5151

5252
@Test
53-
public void supportsParameter() {
53+
public void supportsParameter() throws Exception {
5454
this.resolverComposite.addResolver(new StubArgumentResolver(Integer.class));
5555

5656
assertTrue(this.resolverComposite.supportsParameter(paramInt));

spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerCompositeTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030

3131
/**
3232
* Test fixture with {@link HandlerMethodReturnValueHandlerComposite}.
33+
*
3334
* @author Rossen Stoyanchev
3435
*/
3536
@SuppressWarnings("unused")
@@ -47,8 +48,7 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
4748

4849

4950
@Before
50-
public void setUp() throws Exception {
51-
51+
public void setup() throws Exception {
5252
this.integerType = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1);
5353
this.stringType = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1);
5454

@@ -61,6 +61,7 @@ public void setUp() throws Exception {
6161
mavContainer = new ModelAndViewContainer();
6262
}
6363

64+
6465
@Test
6566
public void supportsReturnType() throws Exception {
6667
assertTrue(this.handlers.supportsReturnType(this.integerType));
@@ -84,9 +85,8 @@ public void handleReturnValueWithMultipleHandlers() throws Exception {
8485
verifyNoMoreInteractions(anotherIntegerHandler);
8586
}
8687

87-
@Test // SPR-13083
88+
@Test // SPR-13083
8889
public void handleReturnValueWithAsyncHandler() throws Exception {
89-
9090
Promise<Integer> promise = new Promise<>();
9191
MethodParameter promiseType = new MethodParameter(getClass().getDeclaredMethod("handlePromise"), -1);
9292

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -129,13 +129,11 @@ private void releaseBody() {
129129

130130
@Override
131131
public ClientResponse build() {
132-
133132
ClientHttpResponse httpResponse =
134133
new BuiltClientHttpResponse(this.statusCode, this.headers, this.cookies, this.body);
135134

136135
// When building ClientResponse manually, the ClientRequest.logPrefix() has to be passed,
137136
// e.g. via ClientResponse.Builder, but this (builder) is not used currently.
138-
139137
return new DefaultClientResponse(httpResponse, this.strategies, "");
140138
}
141139

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public ResponseSpec onStatus(Predicate<HttpStatus> statusPredicate,
423423
private static IntPredicate toIntPredicate(Predicate<HttpStatus> predicate) {
424424
return value -> {
425425
HttpStatus status = HttpStatus.resolve(value);
426-
return (status != null) && predicate.test(status);
426+
return (status != null && predicate.test(status));
427427
};
428428
}
429429

@@ -436,7 +436,6 @@ public ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
436436
}
437437
this.statusHandlers.add(new StatusHandler(statusCodePredicate,
438438
(clientResponse, request) -> exceptionFunction.apply(clientResponse)));
439-
440439
return this;
441440
}
442441

@@ -539,8 +538,6 @@ private static class StatusHandler {
539538
public StatusHandler(IntPredicate predicate,
540539
BiFunction<ClientResponse, HttpRequest, Mono<? extends Throwable>> exceptionFunction) {
541540

542-
Assert.notNull(predicate, "Predicate must not be null");
543-
Assert.notNull(exceptionFunction, "Function must not be null");
544541
this.predicate = predicate;
545542
this.exceptionFunction = exceptionFunction;
546543
}
@@ -552,8 +549,6 @@ public boolean test(int status) {
552549
public Mono<? extends Throwable> apply(ClientResponse response, HttpRequest request) {
553550
return this.exceptionFunction.apply(response, request);
554551
}
555-
556-
557552
}
558553
}
559554

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ <T, P extends Publisher<T>> RequestHeadersSpec<?> body(P publisher,
583583
RequestHeadersSpec<?> syncBody(Object body);
584584
}
585585

586+
586587
/**
587588
* Contract for specifying response operations following the exchange.
588589
*/
@@ -666,24 +667,22 @@ ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
666667
* status code is 4xx or 5xx
667668
*/
668669
<T> Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference);
669-
670670
}
671671

672672

673673
/**
674674
* Contract for specifying request headers and URI for a request.
675-
*
676675
* @param <S> a self reference to the spec type
677676
*/
678677
interface RequestHeadersUriSpec<S extends RequestHeadersSpec<S>>
679678
extends UriSpec<S>, RequestHeadersSpec<S> {
680679
}
681680

681+
682682
/**
683683
* Contract for specifying request headers, body and URI for a request.
684684
*/
685685
interface RequestBodyUriSpec extends RequestBodySpec, RequestHeadersUriSpec<RequestBodySpec> {
686686
}
687687

688-
689688
}

0 commit comments

Comments
 (0)