Skip to content

Commit e8ef365

Browse files
committed
Polishing
1 parent 0434890 commit e8ef365

28 files changed

+132
-118
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ public SuffixByteRange(long suffixLength) {
244244
this.suffixLength = suffixLength;
245245
}
246246

247-
248247
@Override
249248
public long getRangeStart(long length) {
250249
if (this.suffixLength < length) {

spring-web/src/main/java/org/springframework/http/client/OkHttpClientHttpRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,18 @@ public ClientHttpResponse execute() throws IOException {
117117
}
118118
}
119119

120+
120121
private static class OkHttpListenableFuture extends SettableListenableFuture<ClientHttpResponse> {
121122

122123
private final Call call;
123124

124125
public OkHttpListenableFuture(Call call) {
125126
this.call = call;
126127
this.call.enqueue(new Callback() {
127-
128128
@Override
129129
public void onResponse(Response response) {
130130
set(new OkHttpClientHttpResponse(response));
131131
}
132-
133132
@Override
134133
public void onFailure(Request request, IOException ex) {
135134
setException(ex);

spring-web/src/main/java/org/springframework/http/client/OkHttpClientHttpRequestFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,5 @@ public void destroy() throws Exception {
112112
this.client.getDispatcher().getExecutorService().shutdown();
113113
}
114114
}
115+
115116
}

spring-web/src/main/java/org/springframework/http/client/OkHttpClientHttpResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
import org.springframework.util.Assert;
2626

2727
/**
28-
* {@link org.springframework.http.client.ClientHttpResponse} implementation that uses
29-
* OkHttp.
28+
* {@link ClientHttpResponse} implementation based on OkHttp.
3029
*
3130
* @author Luciano Leggieri
3231
* @author Arjen Poutsma
@@ -80,7 +79,8 @@ public void close() {
8079
this.response.body().close();
8180
}
8281
catch (IOException ex) {
83-
// Ignore
82+
// ignore
8483
}
8584
}
85+
8686
}

spring-web/src/main/java/org/springframework/http/converter/AbstractGenericHttpMessageConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected AbstractGenericHttpMessageConverter(MediaType... supportedMediaTypes)
5757
super(supportedMediaTypes);
5858
}
5959

60+
6061
@Override
6162
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
6263
return canRead(contextClass, mediaType);
@@ -78,8 +79,7 @@ public final void write(final T t, final Type type, MediaType contentType, HttpO
7879
addDefaultHeaders(headers, t, contentType);
7980

8081
if (outputMessage instanceof StreamingHttpOutputMessage) {
81-
StreamingHttpOutputMessage streamingOutputMessage =
82-
(StreamingHttpOutputMessage) outputMessage;
82+
StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) outputMessage;
8383
streamingOutputMessage.setBody(new StreamingHttpOutputMessage.Body() {
8484
@Override
8585
public void writeTo(final OutputStream outputStream) throws IOException {
@@ -106,6 +106,7 @@ public HttpHeaders getHeaders() {
106106
@Override
107107
protected void writeInternal(T t, HttpOutputMessage outputMessage)
108108
throws IOException, HttpMessageNotWritableException {
109+
109110
writeInternal(t, null, outputMessage);
110111
}
111112

spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ public HttpHeaders getHeaders() {
201201
* type was not provided, calls {@link #getContentLength}, and sets the corresponding headers
202202
* @since 4.2
203203
*/
204-
protected void addDefaultHeaders(final HttpHeaders headers, final T t, MediaType contentType)
205-
throws IOException{
206-
204+
protected void addDefaultHeaders(HttpHeaders headers, T t, MediaType contentType) throws IOException{
207205
if (headers.getContentType() == null) {
208206
MediaType contentTypeToUse = contentType;
209207
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {

spring-web/src/main/java/org/springframework/web/bind/UnsatisfiedServletRequestParameterException.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,6 @@ public String getMessage() {
8888
return sb.toString();
8989
}
9090

91-
private static String requestParameterMapToString(Map<String, String[]> actualParams) {
92-
StringBuilder result = new StringBuilder();
93-
for (Iterator<Map.Entry<String, String[]>> it = actualParams.entrySet().iterator(); it.hasNext();) {
94-
Map.Entry<String, String[]> entry = it.next();
95-
result.append(entry.getKey()).append('=').append(ObjectUtils.nullSafeToString(entry.getValue()));
96-
if (it.hasNext()) {
97-
result.append(", ");
98-
}
99-
}
100-
return result.toString();
101-
}
102-
10391
/**
10492
* Return the parameter conditions that have been violated or the first group
10593
* in case of multiple groups.
@@ -126,4 +114,17 @@ public final Map<String, String[]> getActualParams() {
126114
return this.actualParams;
127115
}
128116

117+
118+
private static String requestParameterMapToString(Map<String, String[]> actualParams) {
119+
StringBuilder result = new StringBuilder();
120+
for (Iterator<Map.Entry<String, String[]>> it = actualParams.entrySet().iterator(); it.hasNext();) {
121+
Map.Entry<String, String[]> entry = it.next();
122+
result.append(entry.getKey()).append('=').append(ObjectUtils.nullSafeToString(entry.getValue()));
123+
if (it.hasNext()) {
124+
result.append(", ");
125+
}
126+
}
127+
return result.toString();
128+
}
129+
129130
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory) {
116116
* @param asyncRequestFactory the asynchronous request factory
117117
* @param syncRequestFactory the synchronous request factory
118118
*/
119-
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) {
119+
public AsyncRestTemplate(
120+
AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) {
121+
120122
this(asyncRequestFactory, new RestTemplate(syncRequestFactory));
121123
}
122124

@@ -127,7 +129,7 @@ public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory, Clie
127129
* @param restTemplate the synchronous template to use
128130
*/
129131
public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) {
130-
Assert.notNull(restTemplate, "'restTemplate' must not be null");
132+
Assert.notNull(restTemplate, "RestTemplate must not be null");
131133
this.syncTemplate = restTemplate;
132134
setAsyncRequestFactory(requestFactory);
133135
}
@@ -142,7 +144,9 @@ public void setErrorHandler(ResponseErrorHandler errorHandler) {
142144
this.syncTemplate.setErrorHandler(errorHandler);
143145
}
144146

145-
/** Return the error handler. */
147+
/**
148+
* Return the error handler.
149+
*/
146150
public ResponseErrorHandler getErrorHandler() {
147151
return this.syncTemplate.getErrorHandler();
148152
}
@@ -180,7 +184,7 @@ public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters
180184
* Return the message body converters.
181185
*/
182186
public List<HttpMessageConverter<?>> getMessageConverters() {
183-
return syncTemplate.getMessageConverters();
187+
return this.syncTemplate.getMessageConverters();
184188
}
185189

186190

@@ -232,6 +236,7 @@ public ListenableFuture<HttpHeaders> headForHeaders(URI url) throws RestClientEx
232236
return execute(url, HttpMethod.HEAD, null, headersExtractor);
233237
}
234238

239+
235240
// POST
236241

237242
@Override

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public RestTemplate(ClientHttpRequestFactory requestFactory) {
190190
* @since 3.2.7
191191
*/
192192
public RestTemplate(List<HttpMessageConverter<?>> messageConverters) {
193-
Assert.notEmpty(messageConverters, "'messageConverters' must not be empty");
193+
Assert.notEmpty(messageConverters, "At least one HttpMessageConverter required");
194194
this.messageConverters.addAll(messageConverters);
195195
}
196196

@@ -200,7 +200,7 @@ public RestTemplate(List<HttpMessageConverter<?>> messageConverters) {
200200
* <p>These converters are used to convert from and to HTTP requests and responses.
201201
*/
202202
public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
203-
Assert.notEmpty(messageConverters, "'messageConverters' must not be empty");
203+
Assert.notEmpty(messageConverters, "At least one HttpMessageConverter required");
204204
// Take getMessageConverters() List as-is when passed in here
205205
if (this.messageConverters != messageConverters) {
206206
this.messageConverters.clear();
@@ -220,7 +220,7 @@ public List<HttpMessageConverter<?>> getMessageConverters() {
220220
* <p>By default, RestTemplate uses a {@link DefaultResponseErrorHandler}.
221221
*/
222222
public void setErrorHandler(ResponseErrorHandler errorHandler) {
223-
Assert.notNull(errorHandler, "'errorHandler' must not be null");
223+
Assert.notNull(errorHandler, "ResponseErrorHandler must not be null");
224224
this.errorHandler = errorHandler;
225225
}
226226

@@ -237,7 +237,7 @@ public ResponseErrorHandler getErrorHandler() {
237237
* @param handler the URI template handler to use
238238
*/
239239
public void setUriTemplateHandler(UriTemplateHandler handler) {
240-
Assert.notNull(handler, "'uriTemplateHandler' is required.");
240+
Assert.notNull(handler, "UriTemplateHandler must not be null");
241241
this.uriTemplateHandler = handler;
242242
}
243243

0 commit comments

Comments
 (0)