Skip to content

Commit d081a45

Browse files
committed
Polishing
1 parent 97bd0cc commit d081a45

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ public TcpOperations<byte[]> getTcpClient() {
328328

329329
@Override
330330
protected void startInternal() {
331-
332331
this.clientInboundChannel.subscribe(this);
333332
this.brokerChannel.subscribe(this);
334333

@@ -382,7 +381,7 @@ protected void handleMessageInternal(Message<?> message) {
382381
String sessionId = headers.getSessionId();
383382

384383
if (!isBrokerAvailable()) {
385-
if (sessionId == null || sessionId.equals(SystemStompConnectionHandler.SESSION_ID)) {
384+
if (sessionId == null || SystemStompConnectionHandler.SESSION_ID.equals(sessionId)) {
386385
throw new MessageDeliveryException("Message broker is not active.");
387386
}
388387
if (SimpMessageType.CONNECT.equals(headers.getMessageType()) && logger.isErrorEnabled()) {
@@ -574,7 +573,6 @@ protected void afterStompConnected(StompHeaderAccessor connectedHeaders) {
574573
}
575574

576575
private void initHeartbeats(StompHeaderAccessor connectedHeaders) {
577-
// Remote clients do their own heartbeat management
578576
if (this.isRemoteClientSession) {
579577
return;
580578
}

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/ResponseEntity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ public boolean equals(Object other) {
106106
if (this == other) {
107107
return true;
108108
}
109-
if (!(other instanceof ResponseEntity)) {
109+
if (!(other instanceof ResponseEntity) || !super.equals(other)) {
110110
return false;
111111
}
112112
ResponseEntity<?> otherEntity = (ResponseEntity<?>) other;
113-
return (ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode) && super.equals(other));
113+
return ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode);
114114
}
115115

116116
@Override
117117
public int hashCode() {
118-
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode);
118+
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode));
119119
}
120120

121121
@Override

spring-web/src/main/java/org/springframework/web/client/RestOperations.java

Lines changed: 11 additions & 10 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.
@@ -106,6 +106,7 @@ public interface RestOperations {
106106
*/
107107
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException;
108108

109+
109110
// HEAD
110111

111112
/**
@@ -133,6 +134,7 @@ public interface RestOperations {
133134
*/
134135
HttpHeaders headForHeaders(URI url) throws RestClientException;
135136

137+
136138
// POST
137139

138140
/**
@@ -265,6 +267,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
265267
*/
266268
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;
267269

270+
268271
// PUT
269272

270273
/**
@@ -301,6 +304,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
301304
*/
302305
void put(URI url, Object request) throws RestClientException;
303306

307+
304308
// DELETE
305309

306310
/**
@@ -326,6 +330,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
326330
*/
327331
void delete(URI url) throws RestClientException;
328332

333+
329334
// OPTIONS
330335

331336
/**
@@ -353,6 +358,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
353358
*/
354359
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException;
355360

361+
356362
// exchange
357363

358364
/**
@@ -402,20 +408,18 @@ <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> request
402408
* Execute the HTTP method to the given URI template, writing the given
403409
* request entity to the request, and returns the response as {@link ResponseEntity}.
404410
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
405-
*
406411
* <pre class="code">
407412
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
408413
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
409414
* </pre>
410-
*
411415
* @param url the URL
412416
* @param method the HTTP method (GET, POST, etc)
413417
* @param requestEntity the entity (headers and/or body) to write to the
414418
* request, may be {@code null}
415419
* @param responseType the type of the return value
416420
* @param uriVariables the variables to expand in the template
417421
* @return the response as entity
418-
* @since 3.2.0
422+
* @since 3.2
419423
*/
420424
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity,
421425
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException;
@@ -424,19 +428,17 @@ <T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> reque
424428
* Execute the HTTP method to the given URI template, writing the given
425429
* request entity to the request, and returns the response as {@link ResponseEntity}.
426430
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
427-
*
428431
* <pre class="code">
429432
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
430433
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
431434
* </pre>
432-
*
433435
* @param url the URL
434436
* @param method the HTTP method (GET, POST, etc)
435437
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
436438
* @param responseType the type of the return value
437439
* @param uriVariables the variables to expand in the template
438440
* @return the response as entity
439-
* @since 3.2.0
441+
* @since 3.2
440442
*/
441443
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
442444
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
@@ -445,22 +447,21 @@ <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requ
445447
* Execute the HTTP method to the given URI template, writing the given
446448
* request entity to the request, and returns the response as {@link ResponseEntity}.
447449
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
448-
*
449450
* <pre class="code">
450451
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
451452
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
452453
* </pre>
453-
*
454454
* @param url the URL
455455
* @param method the HTTP method (GET, POST, etc)
456456
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
457457
* @param responseType the type of the return value
458458
* @return the response as entity
459-
* @since 3.2.0
459+
* @since 3.2
460460
*/
461461
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
462462
ParameterizedTypeReference<T> responseType) throws RestClientException;
463463

464+
464465
// general execution
465466

466467
/**

spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws
284284
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
285285
}
286286

287+
287288
// HEAD
288289

289290
@Override
@@ -301,6 +302,7 @@ public HttpHeaders headForHeaders(URI url) throws RestClientException {
301302
return execute(url, HttpMethod.HEAD, null, headersExtractor());
302303
}
303304

305+
304306
// POST
305307

306308
@Override
@@ -377,6 +379,7 @@ public <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> res
377379
return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
378380
}
379381

382+
380383
// PUT
381384

382385
@Override
@@ -397,6 +400,7 @@ public void put(URI url, Object request) throws RestClientException {
397400
execute(url, HttpMethod.PUT, requestCallback, null);
398401
}
399402

403+
400404
// DELETE
401405

402406
@Override
@@ -414,6 +418,7 @@ public void delete(URI url) throws RestClientException {
414418
execute(url, HttpMethod.DELETE, null, null);
415419
}
416420

421+
417422
// OPTIONS
418423

419424
@Override
@@ -437,6 +442,7 @@ public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
437442
return headers.getAllow();
438443
}
439444

445+
440446
// exchange
441447

442448
@Override

0 commit comments

Comments
 (0)