Skip to content

Commit a41a5e1

Browse files
committed
Polishing
1 parent 02fdf10 commit a41a5e1

File tree

10 files changed

+60
-73
lines changed

10 files changed

+60
-73
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java

Lines changed: 3 additions & 3 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.
@@ -154,7 +154,6 @@ private void findDefinedEqualsAndHashCodeMethods(Class<?>[] proxiedInterfaces) {
154154
@Override
155155
@Nullable
156156
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
157-
MethodInvocation invocation;
158157
Object oldProxy = null;
159158
boolean setProxyContext = false;
160159

@@ -207,7 +206,8 @@ else if (!this.advised.opaque && method.getDeclaringClass().isInterface() &&
207206
}
208207
else {
209208
// We need to create a method invocation...
210-
invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);
209+
MethodInvocation invocation =
210+
new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);
211211
// Proceed to the joinpoint through the interceptor chain.
212212
retVal = invocation.proceed();
213213
}

spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.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.
@@ -247,7 +247,7 @@ else if (convertedValue instanceof String && !requiredType.isInstance(convertedV
247247
}
248248
}
249249
String trimmedValue = ((String) convertedValue).trim();
250-
if (requiredType.isEnum() && "".equals(trimmedValue)) {
250+
if (requiredType.isEnum() && trimmedValue.isEmpty()) {
251251
// It's an empty enum identifier: reset the enum value to null.
252252
return null;
253253
}
@@ -559,8 +559,7 @@ private Collection<?> convertToTypedCollection(Collection<?> original, @Nullable
559559
return original;
560560
}
561561

562-
int i = 0;
563-
for (; it.hasNext(); i++) {
562+
for (int i = 0; it.hasNext(); i++) {
564563
Object element = it.next();
565564
String indexedPropertyName = buildIndexedPropertyName(propertyName, i);
566565
Object convertedElement = convertIfNecessary(indexedPropertyName, null, element,

spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java

Lines changed: 5 additions & 16 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-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.
@@ -49,7 +49,7 @@ public void testResolvedMappedHandlerWithNoArgCtor() {
4949
}
5050

5151
@Test
52-
public void testNonExistentHandlerClass() throws Exception {
52+
public void testNonExistentHandlerClass() {
5353
String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties";
5454
try {
5555
new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
@@ -61,29 +61,18 @@ public void testNonExistentHandlerClass() throws Exception {
6161
}
6262

6363
@Test
64-
public void testResolveInvalidHandler() throws Exception {
65-
String mappingPath = "org/springframework/beans/factory/xml/support/invalid.properties";
66-
try {
67-
new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
68-
fail("Should not be able to map a class that doesn't implement NamespaceHandler");
69-
}
70-
catch (Throwable expected) {
71-
}
72-
}
73-
74-
@Test
75-
public void testCtorWithNullClassLoaderArgument() throws Exception {
64+
public void testCtorWithNullClassLoaderArgument() {
7665
// simply must not bail...
7766
new DefaultNamespaceHandlerResolver(null);
7867
}
7968

8069
@Test(expected = IllegalArgumentException.class)
81-
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() throws Exception {
70+
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() {
8271
new DefaultNamespaceHandlerResolver(null, null);
8372
}
8473

8574
@Test
86-
public void testCtorWithNonExistentMappingLocationArgument() throws Exception {
75+
public void testCtorWithNonExistentMappingLocationArgument() {
8776
// simply must not bail; we don't want non-existent resources to result in an Exception
8877
new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871");
8978
}

spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 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.
@@ -34,7 +34,7 @@
3434
public class ResourceEditorTests {
3535

3636
@Test
37-
public void sunnyDay() throws Exception {
37+
public void sunnyDay() {
3838
PropertyEditor editor = new ResourceEditor();
3939
editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class");
4040
Resource resource = (Resource) editor.getValue();
@@ -43,19 +43,19 @@ public void sunnyDay() throws Exception {
4343
}
4444

4545
@Test(expected = IllegalArgumentException.class)
46-
public void ctorWithNullCtorArgs() throws Exception {
46+
public void ctorWithNullCtorArgs() {
4747
new ResourceEditor(null, null);
4848
}
4949

5050
@Test
51-
public void setAndGetAsTextWithNull() throws Exception {
51+
public void setAndGetAsTextWithNull() {
5252
PropertyEditor editor = new ResourceEditor();
5353
editor.setAsText(null);
5454
assertEquals("", editor.getAsText());
5555
}
5656

5757
@Test
58-
public void setAndGetAsTextWithWhitespaceResource() throws Exception {
58+
public void setAndGetAsTextWithWhitespaceResource() {
5959
PropertyEditor editor = new ResourceEditor();
6060
editor.setAsText(" ");
6161
assertEquals("", editor.getAsText());
@@ -81,8 +81,6 @@ public void testStrictSystemPropertyReplacement() {
8181
System.setProperty("test.prop", "foo");
8282
try {
8383
editor.setAsText("${test.prop}-${bar}");
84-
Resource resolved = (Resource) editor.getValue();
85-
assertEquals("foo-${bar}", resolved.getFilename());
8684
}
8785
finally {
8886
System.getProperties().remove("test.prop");

spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java

Lines changed: 3 additions & 5 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-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.
@@ -32,7 +32,7 @@
3232
public class ResourceArrayPropertyEditorTests {
3333

3434
@Test
35-
public void testVanillaResource() throws Exception {
35+
public void testVanillaResource() {
3636
PropertyEditor editor = new ResourceArrayPropertyEditor();
3737
editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class");
3838
Resource[] resources = (Resource[]) editor.getValue();
@@ -41,7 +41,7 @@ public void testVanillaResource() throws Exception {
4141
}
4242

4343
@Test
44-
public void testPatternResource() throws Exception {
44+
public void testPatternResource() {
4545
// N.B. this will sometimes fail if you use classpath: instead of classpath*:.
4646
// The result depends on the classpath - if test-classes are segregated from classes
4747
// and they come first on the classpath (like in Maven) then it breaks, if classes
@@ -75,8 +75,6 @@ public void testStrictSystemPropertyReplacement() {
7575
System.setProperty("test.prop", "foo");
7676
try {
7777
editor.setAsText("${test.prop}-${bar}");
78-
Resource[] resources = (Resource[]) editor.getValue();
79-
assertEquals("foo-${bar}", resources[0].getFilename());
8078
}
8179
finally {
8280
System.getProperties().remove("test.prop");

spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.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.
@@ -293,7 +293,7 @@ protected MessageConsumer createListenerConsumer(final Session session) throws J
293293
MessageConsumer consumer = createConsumer(session, destination);
294294

295295
if (this.taskExecutor != null) {
296-
consumer.setMessageListener(message -> taskExecutor.execute(() -> processMessage(message, session)));
296+
consumer.setMessageListener(message -> this.taskExecutor.execute(() -> processMessage(message, session)));
297297
}
298298
else {
299299
consumer.setMessageListener(message -> processMessage(message, session));

spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java

Lines changed: 4 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.
@@ -139,7 +139,7 @@ private static List<MediaType> initMediaTypes(@Nullable HttpMessageWriter<?> for
139139
* @since 5.0.7
140140
*/
141141
public List<HttpMessageWriter<?>> getPartWriters() {
142-
return Collections.unmodifiableList(partWriters);
142+
return Collections.unmodifiableList(this.partWriters);
143143
}
144144

145145
/**
@@ -195,8 +195,8 @@ private boolean isMultipart(MultiValueMap<String, ?> map, @Nullable MediaType co
195195
if (contentType != null) {
196196
return MediaType.MULTIPART_FORM_DATA.includes(contentType);
197197
}
198-
for (String name : map.keySet()) {
199-
for (Object value : map.get(name)) {
198+
for (List<?> values : map.values()) {
199+
for (Object value : values) {
200200
if (value != null && !(value instanceof String)) {
201201
return true;
202202
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ private boolean isMultipart(MultiValueMap<String, ?> map, @Nullable MediaType co
279279
if (contentType != null) {
280280
return MediaType.MULTIPART_FORM_DATA.includes(contentType);
281281
}
282-
for (String name : map.keySet()) {
283-
for (Object value : map.get(name)) {
282+
for (List<?> values : map.values()) {
283+
for (Object value : values) {
284284
if (value != null && !(value instanceof String)) {
285285
return true;
286286
}

spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java

Lines changed: 11 additions & 10 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.
@@ -48,6 +48,7 @@
4848
* @author Juergen Hoeller
4949
* @author Rob Winch
5050
* @since 3.2
51+
* @param <T> the result type
5152
*/
5253
public class DeferredResult<T> {
5354

@@ -57,7 +58,7 @@ public class DeferredResult<T> {
5758

5859

5960
@Nullable
60-
private final Long timeout;
61+
private final Long timeoutValue;
6162

6263
private final Object timeoutResult;
6364

@@ -82,25 +83,25 @@ public DeferredResult() {
8283
}
8384

8485
/**
85-
* Create a DeferredResult with a timeout value.
86+
* Create a DeferredResult with a custom timeout value.
8687
* <p>By default not set in which case the default configured in the MVC
8788
* Java Config or the MVC namespace is used, or if that's not set, then the
8889
* timeout depends on the default of the underlying server.
89-
* @param timeout timeout value in milliseconds
90+
* @param timeoutValue timeout value in milliseconds
9091
*/
91-
public DeferredResult(Long timeout) {
92-
this(timeout, RESULT_NONE);
92+
public DeferredResult(Long timeoutValue) {
93+
this(timeoutValue, RESULT_NONE);
9394
}
9495

9596
/**
9697
* Create a DeferredResult with a timeout value and a default result to use
9798
* in case of timeout.
98-
* @param timeout timeout value in milliseconds (ignored if {@code null})
99+
* @param timeoutValue timeout value in milliseconds (ignored if {@code null})
99100
* @param timeoutResult the result to use
100101
*/
101-
public DeferredResult(@Nullable Long timeout, Object timeoutResult) {
102+
public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) {
102103
this.timeoutResult = timeoutResult;
103-
this.timeout = timeout;
104+
this.timeoutValue = timeoutValue;
104105
}
105106

106107

@@ -141,7 +142,7 @@ public Object getResult() {
141142
*/
142143
@Nullable
143144
final Long getTimeoutValue() {
144-
return this.timeout;
145+
return this.timeoutValue;
145146
}
146147

147148
/**

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java

Lines changed: 22 additions & 20 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.
@@ -68,12 +68,12 @@
6868
*/
6969
public abstract class AbstractSockJsService implements SockJsService, CorsConfigurationSource {
7070

71-
private static final long ONE_YEAR = TimeUnit.DAYS.toSeconds(365);
71+
private static final String XFRAME_OPTIONS_HEADER = "X-Frame-Options";
7272

73-
private static final Random random = new Random();
73+
private static final long ONE_YEAR = TimeUnit.DAYS.toSeconds(365);
7474

75-
private static final String XFRAME_OPTIONS_HEADER = "X-Frame-Options";
7675

76+
private static final Random random = new Random();
7777

7878
protected final Log logger = LogFactory.getLog(getClass());
7979

@@ -286,6 +286,7 @@ public void setSuppressCors(boolean suppressCors) {
286286
}
287287

288288
/**
289+
* Return if automatic addition of CORS headers has been disabled.
289290
* @since 4.1.2
290291
* @see #setSuppressCors(boolean)
291292
*/
@@ -315,6 +316,7 @@ public void setAllowedOrigins(Collection<String> allowedOrigins) {
315316
}
316317

317318
/**
319+
* Return configure allowed {@code Origin} header values.
318320
* @since 4.1.2
319321
* @see #setAllowedOrigins
320322
*/
@@ -349,7 +351,7 @@ public final void handleRequest(ServerHttpRequest request, ServerHttpResponse re
349351
String requestInfo = (logger.isDebugEnabled() ? request.getMethod() + " " + request.getURI() : null);
350352

351353
try {
352-
if (sockJsPath.equals("") || sockJsPath.equals("/")) {
354+
if (sockJsPath.isEmpty() || sockJsPath.equals("/")) {
353355
if (requestInfo != null) {
354356
logger.debug("Processing transport request: " + requestInfo);
355357
}
@@ -571,21 +573,21 @@ else if (request.getMethod() == HttpMethod.OPTIONS) {
571573

572574
private static final String IFRAME_CONTENT =
573575
"<!DOCTYPE html>\n" +
574-
"<html>\n" +
575-
"<head>\n" +
576-
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n" +
577-
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" +
578-
" <script>\n" +
579-
" document.domain = document.domain;\n" +
580-
" _sockjs_onload = function(){SockJS.bootstrap_iframe();};\n" +
581-
" </script>\n" +
582-
" <script src=\"%s\"></script>\n" +
583-
"</head>\n" +
584-
"<body>\n" +
585-
" <h2>Don't panic!</h2>\n" +
586-
" <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n" +
587-
"</body>\n" +
588-
"</html>";
576+
"<html>\n" +
577+
"<head>\n" +
578+
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n" +
579+
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" +
580+
" <script>\n" +
581+
" document.domain = document.domain;\n" +
582+
" _sockjs_onload = function(){SockJS.bootstrap_iframe();};\n" +
583+
" </script>\n" +
584+
" <script src=\"%s\"></script>\n" +
585+
"</head>\n" +
586+
"<body>\n" +
587+
" <h2>Don't panic!</h2>\n" +
588+
" <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n" +
589+
"</body>\n" +
590+
"</html>";
589591

590592
@Override
591593
public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {

0 commit comments

Comments
 (0)