Skip to content

Commit d573bbc

Browse files
committed
Polishing
1 parent f749234 commit d573bbc

File tree

19 files changed

+143
-131
lines changed

19 files changed

+143
-131
lines changed

spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -236,7 +236,7 @@ else if (this.targetPackage != null) {
236236

237237
@Override
238238
public boolean supports(Class<?> clazz) {
239-
Assert.notNull(clazz, "'clazz' must not be null");
239+
Assert.notNull(clazz, "Class must not be null");
240240
if (this.targetClass != null) {
241241
return this.targetClass.equals(clazz);
242242
}

spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java

Lines changed: 2 additions & 2 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-2015 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.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.test.web.client;
1718

1819
import java.io.IOException;
@@ -52,7 +53,6 @@ public MockMvcClientHttpRequestFactory(MockMvc mockMvc) {
5253
@Override
5354
public ClientHttpRequest createRequest(final URI uri, final HttpMethod httpMethod) throws IOException {
5455
return new MockClientHttpRequest(httpMethod, uri) {
55-
5656
@Override
5757
public ClientHttpResponse executeInternal() throws IOException {
5858
try {

spring-test/src/main/java/org/springframework/test/web/client/RequestMatcher.java

Lines changed: 2 additions & 2 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-2015 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.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.test.web.client;
1718

1819
import java.io.IOException;
@@ -29,7 +30,6 @@ public interface RequestMatcher {
2930

3031
/**
3132
* Match the given request against some expectations.
32-
*
3333
* @param request the request to make assertions on
3434
* @throws IOException in case of I/O errors
3535
* @throws AssertionError if expectations are not met

spring-test/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -46,6 +46,7 @@ public RequestMatcherClientHttpRequest(RequestMatcher requestMatcher) {
4646
this.requestMatchers.add(requestMatcher);
4747
}
4848

49+
4950
@Override
5051
public ResponseActions andExpect(RequestMatcher requestMatcher) {
5152
Assert.notNull(requestMatcher, "RequestMatcher is required");
@@ -61,22 +62,19 @@ public void andRespond(ResponseCreator responseCreator) {
6162

6263
@Override
6364
public ClientHttpResponse executeInternal() throws IOException {
64-
6565
if (this.requestMatchers.isEmpty()) {
6666
throw new AssertionError("No request expectations to execute");
6767
}
6868

6969
if (this.responseCreator == null) {
70-
throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, "
71-
+ "e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())");
70+
throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, " +
71+
"e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())");
7272
}
7373

7474
for (RequestMatcher requestMatcher : this.requestMatchers) {
7575
requestMatcher.match(this);
7676
}
77-
7877
setResponse(this.responseCreator.createResponse(this));
79-
8078
return super.executeInternal();
8179
}
8280

spring-test/src/main/java/org/springframework/test/web/client/ResponseActions.java

Lines changed: 2 additions & 1 deletion
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-2015 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.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.test.web.client;
1718

1819
/**

spring-test/src/main/java/org/springframework/test/web/client/ResponseCreator.java

Lines changed: 2 additions & 1 deletion
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-2015 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.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.test.web.client;
1718

1819
import java.io.IOException;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,12 @@ public void setAllow(Set<HttpMethod> allowedMethods) {
448448
public Set<HttpMethod> getAllow() {
449449
String value = getFirst(ALLOW);
450450
if (!StringUtils.isEmpty(value)) {
451-
List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5);
451+
List<HttpMethod> result = new LinkedList<HttpMethod>();
452452
String[] tokens = value.split(",\\s*");
453453
for (String token : tokens) {
454-
allowedMethod.add(HttpMethod.valueOf(token));
454+
result.add(HttpMethod.valueOf(token));
455455
}
456-
return EnumSet.copyOf(allowedMethod);
456+
return EnumSet.copyOf(result);
457457
}
458458
else {
459459
return EnumSet.noneOf(HttpMethod.class);
@@ -468,7 +468,7 @@ public void setCacheControl(String cacheControl) {
468468
}
469469

470470
/**
471-
* Returns the value of the {@code Cache-Control} header.
471+
* Return the value of the {@code Cache-Control} header.
472472
*/
473473
public String getCacheControl() {
474474
return getFirst(CACHE_CONTROL);
@@ -489,7 +489,7 @@ public void setConnection(List<String> connection) {
489489
}
490490

491491
/**
492-
* Returns the value of the {@code Connection} header.
492+
* Return the value of the {@code Connection} header.
493493
*/
494494
public List<String> getConnection() {
495495
return getFirstValueAsList(CONNECTION);
@@ -763,7 +763,7 @@ public void setUpgrade(String upgrade) {
763763
}
764764

765765
/**
766-
* Returns the value of the {@code Upgrade} header.
766+
* Return the value of the {@code Upgrade} header.
767767
*/
768768
public String getUpgrade() {
769769
return getFirst(UPGRADE);

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

Lines changed: 2 additions & 2 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-2015 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.
@@ -26,6 +26,6 @@
2626
*/
2727
public enum HttpMethod {
2828

29-
GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE
29+
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
3030

3131
}

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

Lines changed: 8 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-2015 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.
@@ -23,7 +23,8 @@
2323
import org.springframework.util.Assert;
2424

2525
/**
26-
* Abstract base class for {@link ClientHttpRequestFactory} implementations that decorate another request factory.
26+
* Abstract base class for {@link ClientHttpRequestFactory} implementations
27+
* that decorate another request factory.
2728
*
2829
* @author Arjen Poutsma
2930
* @since 3.1
@@ -34,11 +35,11 @@ public abstract class AbstractClientHttpRequestFactoryWrapper implements ClientH
3435

3536

3637
/**
37-
* Creates a {@code AbstractClientHttpRequestFactoryWrapper} wrapping the given request factory.
38+
* Create a {@code AbstractClientHttpRequestFactoryWrapper} wrapping the given request factory.
3839
* @param requestFactory the request factory to be wrapped
3940
*/
4041
protected AbstractClientHttpRequestFactoryWrapper(ClientHttpRequestFactory requestFactory) {
41-
Assert.notNull(requestFactory, "'requestFactory' must not be null");
42+
Assert.notNull(requestFactory, "ClientHttpRequestFactory must not be null");
4243
this.requestFactory = requestFactory;
4344
}
4445

@@ -50,12 +51,12 @@ protected AbstractClientHttpRequestFactoryWrapper(ClientHttpRequestFactory reque
5051
*/
5152
@Override
5253
public final ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
53-
return createRequest(uri, httpMethod, requestFactory);
54+
return createRequest(uri, httpMethod, this.requestFactory);
5455
}
5556

5657
/**
57-
* Create a new {@link ClientHttpRequest} for the specified URI and HTTP method by using the
58-
* passed-on request factory.
58+
* Create a new {@link ClientHttpRequest} for the specified URI and HTTP method
59+
* by using the passed-on request factory.
5960
* <p>Called from {@link #createRequest(URI, HttpMethod)}.
6061
* @param uri the URI to create a request for
6162
* @param httpMethod the HTTP method to execute

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -114,8 +114,7 @@ public HttpClient getHttpClient() {
114114
*/
115115
public void setConnectTimeout(int timeout) {
116116
Assert.isTrue(timeout >= 0, "Timeout must be a non-negative value");
117-
this.requestConfig = cloneRequestConfig()
118-
.setConnectTimeout(timeout).build();
117+
this.requestConfig = cloneRequestConfig().setConnectTimeout(timeout).build();
119118
setLegacyConnectionTimeout(getHttpClient(), timeout);
120119
}
121120

@@ -136,8 +135,7 @@ public void setConnectTimeout(int timeout) {
136135
@SuppressWarnings("deprecation")
137136
private void setLegacyConnectionTimeout(HttpClient client, int timeout) {
138137
if (org.apache.http.impl.client.AbstractHttpClient.class.isInstance(client)) {
139-
client.getParams().setIntParameter(
140-
org.apache.http.params.CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
138+
client.getParams().setIntParameter(org.apache.http.params.CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
141139
}
142140
}
143141

@@ -151,8 +149,7 @@ private void setLegacyConnectionTimeout(HttpClient client, int timeout) {
151149
* @see RequestConfig#getConnectionRequestTimeout()
152150
*/
153151
public void setConnectionRequestTimeout(int connectionRequestTimeout) {
154-
this.requestConfig = cloneRequestConfig()
155-
.setConnectionRequestTimeout(connectionRequestTimeout).build();
152+
this.requestConfig = cloneRequestConfig().setConnectionRequestTimeout(connectionRequestTimeout).build();
156153
}
157154

158155
/**
@@ -165,8 +162,7 @@ public void setConnectionRequestTimeout(int connectionRequestTimeout) {
165162
*/
166163
public void setReadTimeout(int timeout) {
167164
Assert.isTrue(timeout >= 0, "Timeout must be a non-negative value");
168-
this.requestConfig = cloneRequestConfig()
169-
.setSocketTimeout(timeout).build();
165+
this.requestConfig = cloneRequestConfig().setSocketTimeout(timeout).build();
170166
setLegacySocketTimeout(getHttpClient(), timeout);
171167
}
172168

@@ -180,15 +176,10 @@ public void setReadTimeout(int timeout) {
180176
@SuppressWarnings("deprecation")
181177
private void setLegacySocketTimeout(HttpClient client, int timeout) {
182178
if (org.apache.http.impl.client.AbstractHttpClient.class.isInstance(client)) {
183-
client.getParams().setIntParameter(
184-
org.apache.http.params.CoreConnectionPNames.SO_TIMEOUT, timeout);
179+
client.getParams().setIntParameter(org.apache.http.params.CoreConnectionPNames.SO_TIMEOUT, timeout);
185180
}
186181
}
187182

188-
private RequestConfig.Builder cloneRequestConfig() {
189-
return this.requestConfig != null ? RequestConfig.copy(this.requestConfig) : RequestConfig.custom();
190-
}
191-
192183
/**
193184
* Indicates whether this request factory should buffer the request body internally.
194185
* <p>Default is {@code true}. When sending large amounts of data via POST or PUT, it is
@@ -209,6 +200,7 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
209200
if (context == null) {
210201
context = HttpClientContext.create();
211202
}
203+
212204
// Request configuration not set in the context
213205
if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
214206
// Use request configuration given by the user, when available
@@ -223,6 +215,7 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
223215
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
224216
}
225217
}
218+
226219
if (this.bufferRequestBody) {
227220
return new HttpComponentsClientHttpRequest(client, httpRequest, context);
228221
}
@@ -231,6 +224,11 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
231224
}
232225
}
233226

227+
228+
private RequestConfig.Builder cloneRequestConfig() {
229+
return (this.requestConfig != null ? RequestConfig.copy(this.requestConfig) : RequestConfig.custom());
230+
}
231+
234232
/**
235233
* Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
236234
* @param httpMethod the HTTP method
@@ -241,20 +239,20 @@ protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
241239
switch (httpMethod) {
242240
case GET:
243241
return new HttpGet(uri);
244-
case DELETE:
245-
return new HttpDelete(uri);
246242
case HEAD:
247243
return new HttpHead(uri);
248-
case OPTIONS:
249-
return new HttpOptions(uri);
250244
case POST:
251245
return new HttpPost(uri);
252246
case PUT:
253247
return new HttpPut(uri);
254-
case TRACE:
255-
return new HttpTrace(uri);
256248
case PATCH:
257249
return new HttpPatch(uri);
250+
case DELETE:
251+
return new HttpDelete(uri);
252+
case OPTIONS:
253+
return new HttpOptions(uri);
254+
case TRACE:
255+
return new HttpTrace(uri);
258256
default:
259257
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
260258
}
@@ -312,4 +310,5 @@ public String getMethod() {
312310
return "DELETE";
313311
}
314312
}
313+
315314
}

0 commit comments

Comments
 (0)