diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java index 46b849f4391..00475046197 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,7 +154,6 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa @Override @Nullable public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - MethodInvocation invocation; Object oldProxy = null; boolean setProxyContext = false; @@ -207,7 +206,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa } else { // We need to create a method invocation... - invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain); + MethodInvocation invocation = + new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain); // Proceed to the joinpoint through the interceptor chain. retVal = invocation.proceed(); } diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java index 716065b27e0..feb207939cc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -247,7 +247,7 @@ class TypeConverterDelegate { } } String trimmedValue = ((String) convertedValue).trim(); - if (requiredType.isEnum() && "".equals(trimmedValue)) { + if (requiredType.isEnum() && trimmedValue.isEmpty()) { // It's an empty enum identifier: reset the enum value to null. return null; } @@ -559,8 +559,7 @@ class TypeConverterDelegate { return original; } - int i = 0; - for (; it.hasNext(); i++) { + for (int i = 0; it.hasNext(); i++) { Object element = it.next(); String indexedPropertyName = buildIndexedPropertyName(propertyName, i); Object convertedElement = convertIfNecessary(indexedPropertyName, null, element, diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java index e7dc18fa0b8..54b3cd13268 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class DefaultNamespaceHandlerResolverTests { } @Test - public void testNonExistentHandlerClass() throws Exception { + public void testNonExistentHandlerClass() { String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties"; try { new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath); @@ -61,29 +61,18 @@ public class DefaultNamespaceHandlerResolverTests { } @Test - public void testResolveInvalidHandler() throws Exception { - String mappingPath = "org/springframework/beans/factory/xml/support/invalid.properties"; - try { - new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath); - fail("Should not be able to map a class that doesn't implement NamespaceHandler"); - } - catch (Throwable expected) { - } - } - - @Test - public void testCtorWithNullClassLoaderArgument() throws Exception { + public void testCtorWithNullClassLoaderArgument() { // simply must not bail... new DefaultNamespaceHandlerResolver(null); } @Test(expected = IllegalArgumentException.class) - public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() throws Exception { + public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() { new DefaultNamespaceHandlerResolver(null, null); } @Test - public void testCtorWithNonExistentMappingLocationArgument() throws Exception { + public void testCtorWithNonExistentMappingLocationArgument() { // simply must not bail; we don't want non-existent resources to result in an Exception new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871"); } diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java index f87a0707240..68010cfce5e 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import static org.junit.Assert.*; public class ResourceEditorTests { @Test - public void sunnyDay() throws Exception { + public void sunnyDay() { PropertyEditor editor = new ResourceEditor(); editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class"); Resource resource = (Resource) editor.getValue(); @@ -43,19 +43,19 @@ public class ResourceEditorTests { } @Test(expected = IllegalArgumentException.class) - public void ctorWithNullCtorArgs() throws Exception { + public void ctorWithNullCtorArgs() { new ResourceEditor(null, null); } @Test - public void setAndGetAsTextWithNull() throws Exception { + public void setAndGetAsTextWithNull() { PropertyEditor editor = new ResourceEditor(); editor.setAsText(null); assertEquals("", editor.getAsText()); } @Test - public void setAndGetAsTextWithWhitespaceResource() throws Exception { + public void setAndGetAsTextWithWhitespaceResource() { PropertyEditor editor = new ResourceEditor(); editor.setAsText(" "); assertEquals("", editor.getAsText()); @@ -81,8 +81,6 @@ public class ResourceEditorTests { System.setProperty("test.prop", "foo"); try { editor.setAsText("${test.prop}-${bar}"); - Resource resolved = (Resource) editor.getValue(); - assertEquals("foo-${bar}", resolved.getFilename()); } finally { System.getProperties().remove("test.prop"); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java index 93305ce2c73..38552bd5c03 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import static org.junit.Assert.*; public class ResourceArrayPropertyEditorTests { @Test - public void testVanillaResource() throws Exception { + public void testVanillaResource() { PropertyEditor editor = new ResourceArrayPropertyEditor(); editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class"); Resource[] resources = (Resource[]) editor.getValue(); @@ -41,7 +41,7 @@ public class ResourceArrayPropertyEditorTests { } @Test - public void testPatternResource() throws Exception { + public void testPatternResource() { // N.B. this will sometimes fail if you use classpath: instead of classpath*:. // The result depends on the classpath - if test-classes are segregated from classes // and they come first on the classpath (like in Maven) then it breaks, if classes @@ -75,8 +75,6 @@ public class ResourceArrayPropertyEditorTests { System.setProperty("test.prop", "foo"); try { editor.setAsText("${test.prop}-${bar}"); - Resource[] resources = (Resource[]) editor.getValue(); - assertEquals("foo-${bar}", resources[0].getFilename()); } finally { System.getProperties().remove("test.prop"); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java index 84e4338c4a5..c3c09b7696f 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -293,7 +293,7 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta MessageConsumer consumer = createConsumer(session, destination); if (this.taskExecutor != null) { - consumer.setMessageListener(message -> taskExecutor.execute(() -> processMessage(message, session))); + consumer.setMessageListener(message -> this.taskExecutor.execute(() -> processMessage(message, session))); } else { consumer.setMessageListener(message -> processMessage(message, session)); diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java index b65793521e1..dfcc913bd1d 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,7 +139,7 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter> getPartWriters() { - return Collections.unmodifiableList(partWriters); + return Collections.unmodifiableList(this.partWriters); } /** @@ -195,8 +195,8 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter values : map.values()) { + for (Object value : values) { if (value != null && !(value instanceof String)) { return true; } diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 5c430e2235c..cde051df249 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -279,8 +279,8 @@ public class FormHttpMessageConverter implements HttpMessageConverter values : map.values()) { + for (Object value : values) { if (value != null && !(value instanceof String)) { return true; } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java index 016b80befc8..6c1b26c5f3f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import org.springframework.web.context.request.NativeWebRequest; * @author Juergen Hoeller * @author Rob Winch * @since 3.2 + * @param the result type */ public class DeferredResult { @@ -57,7 +58,7 @@ public class DeferredResult { @Nullable - private final Long timeout; + private final Long timeoutValue; private final Object timeoutResult; @@ -82,25 +83,25 @@ public class DeferredResult { } /** - * Create a DeferredResult with a timeout value. + * Create a DeferredResult with a custom timeout value. *

By default not set in which case the default configured in the MVC * Java Config or the MVC namespace is used, or if that's not set, then the * timeout depends on the default of the underlying server. - * @param timeout timeout value in milliseconds + * @param timeoutValue timeout value in milliseconds */ - public DeferredResult(Long timeout) { - this(timeout, RESULT_NONE); + public DeferredResult(Long timeoutValue) { + this(timeoutValue, RESULT_NONE); } /** * Create a DeferredResult with a timeout value and a default result to use * in case of timeout. - * @param timeout timeout value in milliseconds (ignored if {@code null}) + * @param timeoutValue timeout value in milliseconds (ignored if {@code null}) * @param timeoutResult the result to use */ - public DeferredResult(@Nullable Long timeout, Object timeoutResult) { + public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) { this.timeoutResult = timeoutResult; - this.timeout = timeout; + this.timeoutValue = timeoutValue; } @@ -141,7 +142,7 @@ public class DeferredResult { */ @Nullable final Long getTimeoutValue() { - return this.timeout; + return this.timeoutValue; } /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java index b57b9687e98..d362707d348 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,12 +68,12 @@ import org.springframework.web.util.WebUtils; */ public abstract class AbstractSockJsService implements SockJsService, CorsConfigurationSource { - private static final long ONE_YEAR = TimeUnit.DAYS.toSeconds(365); + private static final String XFRAME_OPTIONS_HEADER = "X-Frame-Options"; - private static final Random random = new Random(); + private static final long ONE_YEAR = TimeUnit.DAYS.toSeconds(365); - private static final String XFRAME_OPTIONS_HEADER = "X-Frame-Options"; + private static final Random random = new Random(); protected final Log logger = LogFactory.getLog(getClass()); @@ -286,6 +286,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig } /** + * Return if automatic addition of CORS headers has been disabled. * @since 4.1.2 * @see #setSuppressCors(boolean) */ @@ -315,6 +316,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig } /** + * Return configure allowed {@code Origin} header values. * @since 4.1.2 * @see #setAllowedOrigins */ @@ -349,7 +351,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig String requestInfo = (logger.isDebugEnabled() ? request.getMethod() + " " + request.getURI() : null); try { - if (sockJsPath.equals("") || sockJsPath.equals("/")) { + if (sockJsPath.isEmpty() || sockJsPath.equals("/")) { if (requestInfo != null) { logger.debug("Processing transport request: " + requestInfo); } @@ -571,21 +573,21 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig private static final String IFRAME_CONTENT = "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "

Don't panic!

\n" + - "

This is a SockJS hidden iframe. It's used for cross domain magic.

\n" + - "\n" + - ""; + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + "

Don't panic!

\n" + + "

This is a SockJS hidden iframe. It's used for cross domain magic.

\n" + + "\n" + + ""; @Override public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {