Skip to content

Commit 86b7118

Browse files
committed
Polishing
1 parent 20c2ba3 commit 86b7118

File tree

18 files changed

+120
-119
lines changed

18 files changed

+120
-119
lines changed

spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class ListenableFutureCallbackRegistry<T> {
4444

4545

4646
/**
47-
* Adds the given callback to this registry.
47+
* Add the given callback to this registry.
4848
* @param callback the callback to add
4949
*/
5050
@SuppressWarnings("unchecked")
@@ -67,7 +67,7 @@ public void addCallback(ListenableFutureCallback<? super T> callback) {
6767
}
6868

6969
/**
70-
* Adds the given success callback to this registry.
70+
* Add the given success callback to this registry.
7171
* @param callback the success callback to add
7272
* @since 4.1
7373
*/
@@ -87,7 +87,7 @@ public void addSuccessCallback(SuccessCallback<? super T> callback) {
8787
}
8888

8989
/**
90-
* Adds the given failure callback to this registry.
90+
* Add the given failure callback to this registry.
9191
* @param callback the failure callback to add
9292
* @since 4.1
9393
*/
@@ -107,8 +107,8 @@ public void addFailureCallback(FailureCallback callback) {
107107
}
108108

109109
/**
110-
* Triggers a {@link ListenableFutureCallback#onSuccess(Object)} call on all
111-
* added callbacks with the given result
110+
* Trigger a {@link ListenableFutureCallback#onSuccess(Object)} call on all
111+
* added callbacks with the given result.
112112
* @param result the result to trigger the callbacks with
113113
*/
114114
public void success(T result) {
@@ -122,7 +122,7 @@ public void success(T result) {
122122
}
123123

124124
/**
125-
* Triggers a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
125+
* Trigger a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
126126
* added callbacks with the given {@code Throwable}.
127127
* @param ex the exception to trigger the callbacks with
128128
*/

spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
import java.io.IOException;
2020
import java.util.concurrent.Callable;
21-
import java.util.concurrent.ExecutionException;
2221

23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.fail;
2522
import org.junit.Test;
2623

27-
import static org.mockito.Mockito.mock;
28-
import static org.mockito.Mockito.verify;
29-
import static org.mockito.Mockito.verifyZeroInteractions;
24+
import static org.junit.Assert.*;
25+
import static org.mockito.Mockito.*;
3026

3127
/**
3228
* @author Arjen Poutsma
@@ -35,7 +31,7 @@
3531
public class ListenableFutureTaskTests {
3632

3733
@Test
38-
public void success() throws ExecutionException, InterruptedException {
34+
public void success() throws Exception {
3935
final String s = "Hello World";
4036
Callable<String> callable = new Callable<String>() {
4137
@Override
@@ -49,7 +45,6 @@ public String call() throws Exception {
4945
public void onSuccess(String result) {
5046
assertEquals(s, result);
5147
}
52-
5348
@Override
5449
public void onFailure(Throwable ex) {
5550
fail(ex.getMessage());
@@ -59,7 +54,7 @@ public void onFailure(Throwable ex) {
5954
}
6055

6156
@Test
62-
public void failure() throws ExecutionException, InterruptedException {
57+
public void failure() throws Exception {
6358
final String s = "Hello World";
6459
Callable<String> callable = new Callable<String>() {
6560
@Override
@@ -73,7 +68,6 @@ public String call() throws Exception {
7368
public void onSuccess(String result) {
7469
fail("onSuccess not expected");
7570
}
76-
7771
@Override
7872
public void onFailure(Throwable ex) {
7973
assertEquals(s, ex.getMessage());
@@ -83,7 +77,7 @@ public void onFailure(Throwable ex) {
8377
}
8478

8579
@Test
86-
public void successWithLambdas() throws ExecutionException, InterruptedException {
80+
public void successWithLambdas() throws Exception {
8781
final String s = "Hello World";
8882
Callable<String> callable = () -> s;
8983
SuccessCallback<String> successCallback = mock(SuccessCallback.class);
@@ -96,7 +90,7 @@ public void successWithLambdas() throws ExecutionException, InterruptedException
9690
}
9791

9892
@Test
99-
public void failureWithLambdas() throws ExecutionException, InterruptedException {
93+
public void failureWithLambdas() throws Exception {
10094
final String s = "Hello World";
10195
IOException ex = new IOException(s);
10296
Callable<String> callable = () -> {

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void setRelayHost(String relayHost) {
158158
}
159159

160160
/**
161-
* @return the STOMP message broker host.
161+
* Return the STOMP message broker host.
162162
*/
163163
public String getRelayHost() {
164164
return this.relayHost;
@@ -172,7 +172,7 @@ public void setRelayPort(int relayPort) {
172172
}
173173

174174
/**
175-
* @return the STOMP message broker port.
175+
* Return the STOMP message broker port.
176176
*/
177177
public int getRelayPort() {
178178
return this.relayPort;
@@ -190,7 +190,7 @@ public void setSystemHeartbeatSendInterval(long systemHeartbeatSendInterval) {
190190
}
191191

192192
/**
193-
* @return The interval, in milliseconds, at which the "system" connection will
193+
* Return the interval, in milliseconds, at which the "system" connection will
194194
* send heartbeats to the STOMP broker.
195195
*/
196196
public long getSystemHeartbeatSendInterval() {
@@ -210,7 +210,7 @@ public void setSystemHeartbeatReceiveInterval(long heartbeatReceiveInterval) {
210210
}
211211

212212
/**
213-
* @return The interval, in milliseconds, at which the "system" connection expects
213+
* Return the interval, in milliseconds, at which the "system" connection expects
214214
* to receive heartbeats from the STOMP broker.
215215
*/
216216
public long getSystemHeartbeatReceiveInterval() {
@@ -238,9 +238,9 @@ public String getClientLogin() {
238238
}
239239

240240
/**
241-
* Set the clientPasscode to use to create connections to the STOMP broker on
241+
* Set the client passcode to use to create connections to the STOMP broker on
242242
* behalf of connected clients.
243-
* <p> By default this is set to "guest".
243+
* <p>By default this is set to "guest".
244244
* @see #setSystemPasscode
245245
*/
246246
public void setClientPasscode(String clientPasscode) {
@@ -249,7 +249,7 @@ public void setClientPasscode(String clientPasscode) {
249249
}
250250

251251
/**
252-
* Return the configured passocde to use for connections to the STOMP broker on
252+
* Return the configured passcode to use for connections to the STOMP broker on
253253
* behalf of connected clients.
254254
* @see #getSystemPasscode()
255255
*/
@@ -269,7 +269,7 @@ public void setSystemLogin(String systemLogin) {
269269
}
270270

271271
/**
272-
* Return the login used for the shared "system" connection to the STOMP broker
272+
* Return the login used for the shared "system" connection to the STOMP broker.
273273
*/
274274
public String getSystemLogin() {
275275
return this.systemLogin;
@@ -286,7 +286,7 @@ public void setSystemPasscode(String systemPasscode) {
286286
}
287287

288288
/**
289-
* @return the passcode used for the shared "system" connection to the STOMP broker
289+
* Return the passcode used for the shared "system" connection to the STOMP broker.
290290
*/
291291
public String getSystemPasscode() {
292292
return this.systemPasscode;
@@ -305,7 +305,7 @@ public void setVirtualHost(String virtualHost) {
305305
}
306306

307307
/**
308-
* @return the configured virtual host value.
308+
* Return the configured virtual host value.
309309
*/
310310
public String getVirtualHost() {
311311
return this.virtualHost;
@@ -419,7 +419,7 @@ protected void handleMessageInternal(Message<?> message) {
419419
"receive BrokerAvailabilityEvent's from an ApplicationListener Spring bean.");
420420
}
421421
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders());
422-
if (logger.isErrorEnabled() && messageType.equals(SimpMessageType.CONNECT)) {
422+
if (logger.isErrorEnabled() && SimpMessageType.CONNECT.equals(messageType)) {
423423
logger.error("Broker not active. Ignoring " + message);
424424
}
425425
else if (logger.isDebugEnabled()) {
@@ -464,7 +464,7 @@ else if (accessor instanceof SimpMessageHeaderAccessor) {
464464
}
465465

466466
String destination = stompAccessor.getDestination();
467-
if ((command != null) && command.requiresDestination() && !checkDestinationPrefix(destination)) {
467+
if (command != null && command.requiresDestination() && !checkDestinationPrefix(destination)) {
468468
return;
469469
}
470470

@@ -673,12 +673,12 @@ public void run() {
673673
}
674674

675675
@Override
676-
public void handleFailure(Throwable failure) {
676+
public void handleFailure(Throwable ex) {
677677
if (this.tcpConnection != null) {
678-
handleTcpConnectionFailure("transport failure.", failure);
678+
handleTcpConnectionFailure("transport failure.", ex);
679679
}
680680
else if (logger.isErrorEnabled()) {
681-
logger.error("Transport failure: " + failure);
681+
logger.error("Transport failure: " + ex);
682682
}
683683
}
684684

@@ -699,7 +699,7 @@ public void afterConnectionClosed() {
699699
this.tcpConnection = null;
700700
clearConnection();
701701
}
702-
catch (Throwable t) {
702+
catch (Throwable ex) {
703703
// Shouldn't happen with connection reset beforehand
704704
}
705705
}
@@ -742,7 +742,7 @@ public ListenableFuture<Void> forward(final Message<?> message, final StompHeade
742742
(conn != null ? "before STOMP CONNECTED. " : "while inactive. ") +
743743
"Consider subscribing to receive BrokerAvailabilityEvent's from " +
744744
"an ApplicationListener Spring bean. Dropped " +
745-
accessor.getShortLogMessage((byte[]) message.getPayload()));
745+
accessor.getShortLogMessage(message.getPayload()));
746746
}
747747
}
748748

@@ -842,8 +842,8 @@ protected void afterStompConnected(StompHeaderAccessor connectedHeaders) {
842842
}
843843

844844
@Override
845-
protected void handleTcpConnectionFailure(String error, Throwable t) {
846-
super.handleTcpConnectionFailure(error, t);
845+
protected void handleTcpConnectionFailure(String errorMessage, Throwable ex) {
846+
super.handleTcpConnectionFailure(errorMessage, ex);
847847
publishBrokerUnavailableEvent();
848848
}
849849

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -138,20 +138,20 @@ public boolean equals(Object other) {
138138

139139
@Override
140140
public int hashCode() {
141-
return ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body);
141+
return (ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body));
142142
}
143143

144144
@Override
145145
public String toString() {
146146
StringBuilder builder = new StringBuilder("<");
147-
if (body != null) {
148-
builder.append(body);
149-
if (headers != null) {
147+
if (this.body != null) {
148+
builder.append(this.body);
149+
if (this.headers != null) {
150150
builder.append(',');
151151
}
152152
}
153-
if (headers != null) {
154-
builder.append(headers);
153+
if (this.headers != null) {
154+
builder.append(this.headers);
155155
}
156156
builder.append('>');
157157
return builder.toString();

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,20 @@ public boolean equals(Object other) {
128128
if (this == other) {
129129
return true;
130130
}
131-
if (!(other instanceof RequestEntity)) {
131+
if (!(other instanceof RequestEntity) || !super.equals(other)) {
132132
return false;
133133
}
134134
RequestEntity<?> otherEntity = (RequestEntity<?>) other;
135135
return (ObjectUtils.nullSafeEquals(this.method, otherEntity.method) &&
136-
ObjectUtils.nullSafeEquals(this.url, otherEntity.url) &&
137-
super.equals(other));
136+
ObjectUtils.nullSafeEquals(this.url, otherEntity.url));
138137
}
139138

140139
@Override
141140
public int hashCode() {
142-
return 29 * super.hashCode() +
143-
29 * ObjectUtils.nullSafeHashCode(this.method) +
144-
ObjectUtils.nullSafeHashCode(this.url);
141+
int hashCode = super.hashCode();
142+
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.method);
143+
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.url);
144+
return hashCode;
145145
}
146146

147147
@Override
@@ -166,6 +166,7 @@ public String toString() {
166166
return builder.toString();
167167
}
168168

169+
169170
// Static builder methods
170171

171172
/**
@@ -422,6 +423,7 @@ public static HeadersBuilder<?> options(URI url) {
422423
return method(HttpMethod.OPTIONS, url);
423424
}
424425

426+
425427
/**
426428
* Defines a builder that adds headers to the request entity.
427429
* @param <B> the builder subclass
@@ -471,9 +473,9 @@ public interface HeadersBuilder<B extends HeadersBuilder<B>> {
471473
* @see BodyBuilder#body(Object)
472474
*/
473475
RequestEntity<Void> build();
474-
475476
}
476477

478+
477479
/**
478480
* Defines a builder that adds a body to the response entity.
479481
*/
@@ -504,9 +506,9 @@ public interface BodyBuilder extends HeadersBuilder<BodyBuilder> {
504506
* @return the built request entity
505507
*/
506508
<T> RequestEntity<T> body(T body);
507-
508509
}
509510

511+
510512
private static class DefaultBodyBuilder implements BodyBuilder {
511513

512514
private final HttpMethod method;
@@ -515,7 +517,6 @@ private static class DefaultBodyBuilder implements BodyBuilder {
515517

516518
private final HttpHeaders headers = new HttpHeaders();
517519

518-
519520
public DefaultBodyBuilder(HttpMethod method, URI url) {
520521
this.method = method;
521522
this.url = url;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ public boolean equals(Object other) {
121121
if (this == other) {
122122
return true;
123123
}
124-
if (!(other instanceof ResponseEntity)) {
124+
if (!(other instanceof ResponseEntity) || !super.equals(other)) {
125125
return false;
126126
}
127127
ResponseEntity<?> otherEntity = (ResponseEntity<?>) other;
128-
return (ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode) && super.equals(other));
128+
return ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode);
129129
}
130130

131131
@Override
132132
public int hashCode() {
133-
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode);
133+
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode));
134134
}
135135

136136
@Override

0 commit comments

Comments
 (0)