From 717bd2c58099e3ff9b5de66bc8e6076436f3ef31 Mon Sep 17 00:00:00 2001 From: igor-suhorukov Date: Sat, 27 Jan 2018 15:13:04 +0300 Subject: [PATCH 1/2] Remove or use unused method parameters --- .../cloudfoundry/CloudFoundryAuthorizationException.java | 2 +- .../properties/ConfigurationPropertiesReportEndpoint.java | 6 ++---- .../metrics/integration/SpringIntegrationMetrics.java | 2 +- .../boot/autoconfigure/condition/BeanTypeRegistry.java | 6 +++--- .../autoconfigure/session/AbstractSessionCondition.java | 3 +-- .../boot/autoconfigure/session/SessionStoreMappings.java | 3 +-- .../boot/cli/compiler/ExtendedGroovyClassLoader.java | 4 ++-- .../springframework/boot/cli/compiler/GroovyCompiler.java | 3 +-- .../boot/cli/compiler/SmartImportCustomizer.java | 5 +---- .../autoconfigure/SpringBootCompilerAutoConfiguration.java | 5 ++--- .../boot/devtools/livereload/Connection.java | 4 ++-- .../boot/test/mock/mockito/MockitoPostProcessor.java | 7 +++---- .../reactive/server/WebTestClientContextCustomizer.java | 5 ++--- .../springframework/boot/loader/jar/JarFileEntries.java | 5 ++--- .../boot/context/config/ConfigFileApplicationListener.java | 5 ++--- .../boot/context/properties/bind/Binder.java | 5 ++--- .../source/SpringIterableConfigurationPropertySource.java | 5 ++--- .../boot/web/embedded/tomcat/TomcatErrorPage.java | 4 ++-- .../boot/web/embedded/tomcat/TomcatWebServer.java | 4 ++-- .../boot/web/embedded/undertow/SslBuilderCustomizer.java | 4 ++-- .../boot/web/servlet/ServletComponentHandler.java | 2 +- 21 files changed, 37 insertions(+), 52 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java index 099df541784..adadcabc614 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java @@ -34,7 +34,7 @@ public class CloudFoundryAuthorizationException extends RuntimeException { public CloudFoundryAuthorizationException(Reason reason, String message, Throwable cause) { - super(message); + super(message, cause); this.reason = reason; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index afc6b8356a8..6ef084007f5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -115,7 +115,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext for (Map.Entry entry : beans.entrySet()) { String beanName = entry.getKey(); Object bean = entry.getValue(); - String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean); + String prefix = extractPrefix(context, beanFactoryMetaData, beanName); beanDescriptors.put(beanName, new ConfigurationPropertiesBeanDescriptor( prefix, sanitize(prefix, safeSerialize(mapper, bean, prefix)))); } @@ -201,12 +201,10 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext * @param context the application context * @param beanFactoryMetaData the bean factory meta-data * @param beanName the bean name - * @param bean the bean * @return the prefix */ private String extractPrefix(ApplicationContext context, - ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName, - Object bean) { + ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName) { ConfigurationProperties annotation = context.findAnnotationOnBean(beanName, ConfigurationProperties.class); if (beanFactoryMetaData != null) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetrics.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetrics.java index c85ad8d481d..528bfe288f1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetrics.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetrics.java @@ -136,7 +136,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS private void registerGauge(MeterRegistry registry, T object, Iterable tags, String name, String description, ToDoubleFunction value) { Gauge.Builder builder = Gauge.builder(name, object, value); - builder.tags(this.tags).description(description).register(registry); + builder.tags(tags).description(description).register(registry); } private void registerTimedGauge(MeterRegistry registry, T object, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index f29ad405e7a..6bb0ac0f805 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -237,7 +237,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name); } if (StringUtils.hasLength(definition.getBeanClassName())) { - return getDirectFactoryBeanGeneric(beanFactory, definition, name); + return getDirectFactoryBeanGeneric(beanFactory, definition); } return null; } @@ -305,8 +305,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } private Class getDirectFactoryBeanGeneric( - ConfigurableListableBeanFactory beanFactory, BeanDefinition definition, - String name) throws ClassNotFoundException, LinkageError { + ConfigurableListableBeanFactory beanFactory, + BeanDefinition definition) throws ClassNotFoundException, LinkageError { Class factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(), beanFactory.getBeanClassLoader()); Class generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java index e8ba662cb23..0bf342e9d1d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java @@ -49,8 +49,7 @@ abstract class AbstractSessionCondition extends SpringBootCondition { ConditionMessage.Builder message = ConditionMessage .forCondition("Session Condition"); Environment environment = context.getEnvironment(); - StoreType required = SessionStoreMappings.getType(this.webApplicationType, - ((AnnotationMetadata) metadata).getClassName()); + StoreType required = SessionStoreMappings.getType(((AnnotationMetadata) metadata).getClassName()); if (!environment.containsProperty("spring.session.store-type")) { return ConditionOutcome.match(message.didNotFind("property", "properties") .items(ConditionMessage.Style.QUOTE, "spring.session.store-type")); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java index a6c93be19ee..380a76a848a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java @@ -80,8 +80,7 @@ final class SessionStoreMappings { return configurationClass.getName(); } - static StoreType getType(WebApplicationType webApplicationType, - String configurationClassName) { + static StoreType getType(String configurationClassName) { for (Map.Entry>> storeEntry : MAPPINGS .entrySet()) { for (Map.Entry> entry : storeEntry.getValue() diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java index 782edec4d36..4f2c4accc8b 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java @@ -183,7 +183,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader { Set urls = new HashSet<>(); findGroovyJarsDirectly(parent, urls); if (urls.isEmpty()) { - findGroovyJarsFromClassPath(parent, urls); + findGroovyJarsFromClassPath(urls); } Assert.state(!urls.isEmpty(), "Unable to find groovy JAR"); return new ArrayList<>(urls).toArray(new URL[urls.size()]); @@ -202,7 +202,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader { } } - private void findGroovyJarsFromClassPath(ClassLoader parent, Set urls) { + private void findGroovyJarsFromClassPath(Set urls) { String classpath = System.getProperty("java.class.path"); String[] entries = classpath.split(System.getProperty("path.separator")); for (String entry : entries) { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java index a2aa200b8be..3b1092ce14f 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java @@ -280,8 +280,7 @@ public class GroovyCompiler { public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException { - ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context, - classNode); + ImportCustomizer importCustomizer = new SmartImportCustomizer(source); ClassNode mainClassNode = MainClass.get(source.getAST().getClasses()); // Additional auto configuration diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java index 0261670149e..29ca0da1128 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java @@ -17,8 +17,6 @@ package org.springframework.boot.cli.compiler; import org.codehaus.groovy.ast.ClassHelper; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.classgen.GeneratorContext; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.control.customizers.ImportCustomizer; @@ -33,8 +31,7 @@ class SmartImportCustomizer extends ImportCustomizer { private SourceUnit source; - SmartImportCustomizer(SourceUnit source, GeneratorContext context, - ClassNode classNode) { + SmartImportCustomizer(SourceUnit source) { this.source = source; } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java index cc83da86373..d5392997d51 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java @@ -80,11 +80,10 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati public void applyToMainClass(GroovyClassLoader loader, GroovyCompilerConfiguration configuration, GeneratorContext generatorContext, SourceUnit source, ClassNode classNode) throws CompilationFailedException { - addEnableAutoConfigurationAnnotation(source, classNode); + addEnableAutoConfigurationAnnotation(classNode); } - private void addEnableAutoConfigurationAnnotation(SourceUnit source, - ClassNode classNode) { + private void addEnableAutoConfigurationAnnotation(ClassNode classNode) { if (!hasEnableAutoConfigureAnnotation(classNode)) { AnnotationNode annotationNode = new AnnotationNode( ClassHelper.make("EnableAutoConfiguration")); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java index 4b0c257a724..0188426f8db 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java @@ -80,7 +80,7 @@ class Connection { public void run() throws Exception { if (this.header.contains("Upgrade: websocket") && this.header.contains("Sec-WebSocket-Version: 13")) { - runWebSocket(this.header); + runWebSocket(); } if (this.header.contains("GET /livereload.js")) { this.outputStream.writeHttp(getClass().getResourceAsStream("livereload.js"), @@ -88,7 +88,7 @@ class Connection { } } - private void runWebSocket(String header) throws Exception { + private void runWebSocket() throws Exception { String accept = getWebsocketAcceptResponse(); this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols", "Upgrade: websocket", "Connection: Upgrade", diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java index a84186e7a62..d756f452df1 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java @@ -372,7 +372,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda private void postProcessField(Object bean, Field field) { RegisteredField registered = this.fieldRegistry.get(field); if (registered != null && StringUtils.hasLength(registered.getBeanName())) { - inject(field, bean, registered.getBeanName(), registered.getDefinition()); + inject(field, bean, registered.getBeanName()); } } @@ -380,11 +380,10 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda String beanName = this.beanNameRegistry.get(definition); Assert.state(StringUtils.hasLength(beanName), () -> "No bean found for definition " + definition); - inject(field, target, beanName, definition); + inject(field, target, beanName); } - private void inject(Field field, Object target, String beanName, - Definition definition) { + private void inject(Field field, Object target, String beanName) { try { field.setAccessible(true); Assert.state(ReflectionUtils.getField(field, target) == null, diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java index a7550cec261..0ebfeb5b202 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java @@ -65,12 +65,11 @@ class WebTestClientContextCustomizer implements ContextCustomizer { private void registerWebTestClient(ConfigurableApplicationContext context) { ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); if (beanFactory instanceof BeanDefinitionRegistry) { - registerWebTestClient(context, (BeanDefinitionRegistry) context); + registerWebTestClient((BeanDefinitionRegistry) context); } } - private void registerWebTestClient(ConfigurableApplicationContext context, - BeanDefinitionRegistry registry) { + private void registerWebTestClient(BeanDefinitionRegistry registry) { RootBeanDefinition definition = new RootBeanDefinition( WebTestClientRegistrar.class); definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index f583172a477..0085b2fe344 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -99,12 +99,11 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { public void visitFileHeader(CentralDirectoryFileHeader fileHeader, int dataOffset) { AsciiBytes name = applyFilter(fileHeader.getName()); if (name != null) { - add(name, fileHeader, dataOffset); + add(name, dataOffset); } } - private void add(AsciiBytes name, CentralDirectoryFileHeader fileHeader, - int dataOffset) { + private void add(AsciiBytes name, int dataOffset) { this.hashCodes[this.size] = name.hashCode(); this.centralDirectoryOffsets[this.size] = dataOffset; this.positions[this.size] = this.size; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index f09298c129d..61b8d5dffb8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -451,7 +451,7 @@ public class ConfigFileApplicationListener String loadProfile) { try { Resource resource = this.resourceLoader.getResource(location); - String description = getDescription(profile, location, resource); + String description = getDescription(location, resource); if (profile != null) { description = description + " for profile " + profile; } @@ -482,8 +482,7 @@ public class ConfigFileApplicationListener } } - private String getDescription(Profile profile, String location, - Resource resource) { + private String getDescription(String location, Resource resource) { try { if (resource != null) { String uri = resource.getURI().toASCIIString(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index fe9e2c50d84..9750aad885f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -246,7 +246,7 @@ public class Binder { } if (property != null) { try { - return bindProperty(name, target, handler, context, property); + return bindProperty(target, context, property); } catch (ConverterNotFoundException ex) { // We might still be able to bind it as a bean @@ -295,8 +295,7 @@ public class Binder { .filter(Objects::nonNull).findFirst().orElse(null); } - private Object bindProperty(ConfigurationPropertyName name, Bindable target, - BindHandler handler, Context context, ConfigurationProperty property) { + private Object bindProperty(Bindable target, Context context, ConfigurationProperty property) { context.setConfigurationProperty(property); Object result = property.getValue(); result = this.placeholdersResolver.resolvePlaceholders(result); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java index 2faaf570bff..71141454559 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java @@ -49,11 +49,10 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope SpringIterableConfigurationPropertySource(EnumerablePropertySource propertySource, PropertyMapper mapper) { super(propertySource, mapper, null); - assertEnumerablePropertySource(propertySource); + assertEnumerablePropertySource(); } - private void assertEnumerablePropertySource( - EnumerablePropertySource propertySource) { + private void assertEnumerablePropertySource() { if (getPropertySource() instanceof MapPropertySource) { try { ((MapPropertySource) getPropertySource()).getSource().size(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java index 93d25fb2a05..0e13935ad89 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java @@ -48,10 +48,10 @@ class TomcatErrorPage { this.location = errorPage.getPath(); this.exceptionType = errorPage.getExceptionName(); this.errorCode = errorPage.getStatusCode(); - this.nativePage = createNativePage(errorPage); + this.nativePage = createNativePage(); } - private Object createNativePage(ErrorPage errorPage) { + private Object createNativePage() { try { if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) { return BeanUtils diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index 93106b8f7e5..dc272d6a5ec 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -190,7 +190,7 @@ public class TomcatWebServer implements WebServer { addPreviouslyRemovedConnectors(); Connector connector = this.tomcat.getConnector(); if (connector != null && this.autoStart) { - startConnector(connector); + startConnector(); } checkThatConnectorsHaveStarted(); this.started = true; @@ -264,7 +264,7 @@ public class TomcatWebServer implements WebServer { } } - private void startConnector(Connector connector) { + private void startConnector() { try { for (Container child : this.tomcat.getHost().findChildren()) { if (child instanceof TomcatEmbeddedContext) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java index 218b97c0262..04f6061c7cf 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java @@ -72,7 +72,7 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { SSLContext sslContext = SSLContext.getInstance(this.ssl.getProtocol()); sslContext.init(getKeyManagers(this.ssl, this.sslStoreProvider), getTrustManagers(this.ssl, this.sslStoreProvider), null); - builder.addHttpsListener(this.port, getListenAddress(this.address), + builder.addHttpsListener(this.port, getListenAddress(), sslContext); builder.setSocketOption(Options.SSL_CLIENT_AUTH_MODE, getSslClientAuthMode(this.ssl)); @@ -93,7 +93,7 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { } } - private String getListenAddress(InetAddress address) { + private String getListenAddress() { if (this.address == null) { return "0.0.0.0"; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java index fac24430c10..ca5cdac9412 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java @@ -51,7 +51,7 @@ abstract class ServletComponentHandler { protected String[] extractUrlPatterns(String attribute, Map attributes) { String[] value = (String[]) attributes.get("value"); - String[] urlPatterns = (String[]) attributes.get("urlPatterns"); + String[] urlPatterns = (String[]) attributes.get(attribute); if (urlPatterns.length > 0) { Assert.state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive."); From 875091ed85c3571c1e830bd810c963c05e4b213e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 1 Feb 2018 20:36:47 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Polish=20=E2=80=9CRemove=20or=20use=20unuse?= =?UTF-8?q?d=20method=20parameters=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes gh-11812 --- .../CloudFoundryAuthorizationException.java | 2 +- .../MappingsEndpointAutoConfiguration.java | 3 +- .../annotation/RequestPredicateFactory.java | 4 +- .../metrics/jdbc/DataSourcePoolMetrics.java | 6 +-- .../condition/BeanTypeRegistry.java | 19 +++++----- .../session/AbstractSessionCondition.java | 5 ++- .../session/SessionAutoConfiguration.java | 9 ++--- .../session/SessionStoreMappings.java | 6 ++- .../cli/compiler/SmartImportCustomizer.java | 2 +- .../SpringBootCompilerAutoConfiguration.java | 2 +- .../json/JsonTestersAutoConfiguration.java | 25 +++++++----- .../boot/test/json/BasicJsonTester.java | 12 ++---- .../mock/mockito/MockitoPostProcessor.java | 38 ++++--------------- ...TestRestTemplateTestContextCustomizer.java | 5 +-- .../boot/loader/jar/JarFileEntries.java | 2 +- .../context/properties/bind/ArrayBinder.java | 5 +-- .../boot/context/properties/bind/Binder.java | 3 +- .../properties/bind/CollectionBinder.java | 4 +- .../bind/IndexedElementsBinder.java | 4 +- ...ngIterableConfigurationPropertySource.java | 2 +- .../web/embedded/tomcat/TomcatErrorPage.java | 2 +- .../undertow/SslBuilderCustomizer.java | 5 +-- .../web/servlet/ServletComponentHandler.java | 7 ++-- .../boot/web/servlet/WebFilterHandler.java | 5 +-- .../boot/web/servlet/WebServletHandler.java | 5 +-- 25 files changed, 76 insertions(+), 106 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java index adadcabc614..010e5767116 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java index 622ce38fd22..6c14809f293 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java @@ -77,8 +77,7 @@ public class MappingsEndpointAutoConfiguration { static class SpringMvcConfiguration { @Bean - DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider( - ApplicationContext applicationContext) { + DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider() { return new DispatcherServletsMappingDescriptionProvider(); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/RequestPredicateFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/RequestPredicateFactory.java index f9625520430..8ce5291b814 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/RequestPredicateFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/RequestPredicateFactory.java @@ -53,7 +53,7 @@ class RequestPredicateFactory { public WebOperationRequestPredicate getRequestPredicate(String endpointId, String rootPath, DiscoveredOperationMethod operationMethod) { Method method = operationMethod.getMethod(); - String path = getPath(endpointId, rootPath, method); + String path = getPath(rootPath, method); WebEndpointHttpMethod httpMethod = determineHttpMethod( operationMethod.getOperationType()); Collection consumes = getConsumes(httpMethod, method); @@ -61,7 +61,7 @@ class RequestPredicateFactory { return new WebOperationRequestPredicate(path, httpMethod, consumes, produces); } - private String getPath(String endpointId, String rootPath, Method method) { + private String getPath(String rootPath, Method method) { return rootPath + Stream.of(method.getParameters()).filter(this::hasSelector) .map(this::slashName).collect(Collectors.joining()); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java index f958006b528..7d71193e867 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -62,7 +62,7 @@ public class DataSourcePoolMetrics implements MeterBinder { Assert.notNull(dataSource, "DataSource must not be null"); Assert.notNull(metadataProvider, "MetadataProvider must not be null"); this.dataSource = dataSource; - this.metadataProvider = new CachingDataSourcePoolMetadataProvider(dataSource, + this.metadataProvider = new CachingDataSourcePoolMetadataProvider( metadataProvider); this.name = name; this.tags = tags; @@ -97,7 +97,7 @@ public class DataSourcePoolMetrics implements MeterBinder { private final DataSourcePoolMetadataProvider metadataProvider; - CachingDataSourcePoolMetadataProvider(DataSource dataSource, + CachingDataSourcePoolMetadataProvider( DataSourcePoolMetadataProvider metadataProvider) { this.metadataProvider = metadataProvider; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index 6bb0ac0f805..a794c2e4009 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -167,7 +167,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { String factoryName = BeanFactory.FACTORY_BEAN_PREFIX + name; if (this.beanFactory.isFactoryBean(factoryName)) { Class factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory, - beanDefinition, name); + beanDefinition); this.beanTypes.put(name, factoryBeanGeneric); this.beanTypes.put(factoryName, this.beanFactory.getType(factoryName)); @@ -216,13 +216,12 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { * generics in its method signature. * @param beanFactory the source bean factory * @param definition the bean definition - * @param name the name of the bean * @return the generic type of the {@link FactoryBean} or {@code null} */ private Class getFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory, - BeanDefinition definition, String name) { + BeanDefinition definition) { try { - return doGetFactoryBeanGeneric(beanFactory, definition, name); + return doGetFactoryBeanGeneric(beanFactory, definition); } catch (Exception ex) { return null; @@ -230,11 +229,11 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } private Class doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory, - BeanDefinition definition, String name) + BeanDefinition definition) throws Exception, ClassNotFoundException, LinkageError { if (StringUtils.hasLength(definition.getFactoryBeanName()) && StringUtils.hasLength(definition.getFactoryMethodName())) { - return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name); + return getConfigurationClassFactoryBeanGeneric(beanFactory, definition); } if (StringUtils.hasLength(definition.getBeanClassName())) { return getDirectFactoryBeanGeneric(beanFactory, definition); @@ -243,8 +242,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } private Class getConfigurationClassFactoryBeanGeneric( - ConfigurableListableBeanFactory beanFactory, BeanDefinition definition, - String name) throws Exception { + ConfigurableListableBeanFactory beanFactory, BeanDefinition definition) + throws Exception { Method method = getFactoryMethod(beanFactory, definition); Class generic = ResolvableType.forMethodReturnType(method) .as(FactoryBean.class).resolveGeneric(); @@ -305,8 +304,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } private Class getDirectFactoryBeanGeneric( - ConfigurableListableBeanFactory beanFactory, - BeanDefinition definition) throws ClassNotFoundException, LinkageError { + ConfigurableListableBeanFactory beanFactory, BeanDefinition definition) + throws ClassNotFoundException, LinkageError { Class factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(), beanFactory.getBeanClassLoader()); Class generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java index 0bf342e9d1d..a23c1c75081 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/AbstractSessionCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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,8 @@ abstract class AbstractSessionCondition extends SpringBootCondition { ConditionMessage.Builder message = ConditionMessage .forCondition("Session Condition"); Environment environment = context.getEnvironment(); - StoreType required = SessionStoreMappings.getType(((AnnotationMetadata) metadata).getClassName()); + StoreType required = SessionStoreMappings.getType(this.webApplicationType, + ((AnnotationMetadata) metadata).getClassName()); if (!environment.containsProperty("spring.session.store-type")) { return ConditionOutcome.match(message.didNotFind("property", "properties") .items(ConditionMessage.Style.QUOTE, "spring.session.store-type")); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java index 6d473e14d98..4c7a5e2335a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java @@ -106,8 +106,7 @@ public class SessionAutoConfiguration { */ abstract static class SessionConfigurationImportSelector implements ImportSelector { - protected final String[] selectImports(AnnotationMetadata importingClassMetadata, - WebApplicationType webApplicationType) { + protected final String[] selectImports(WebApplicationType webApplicationType) { List imports = new ArrayList<>(); StoreType[] types = StoreType.values(); for (int i = 0; i < types.length; i++) { @@ -128,8 +127,7 @@ public class SessionAutoConfiguration { @Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { - return super.selectImports(importingClassMetadata, - WebApplicationType.REACTIVE); + return super.selectImports(WebApplicationType.REACTIVE); } } @@ -143,8 +141,7 @@ public class SessionAutoConfiguration { @Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { - return super.selectImports(importingClassMetadata, - WebApplicationType.SERVLET); + return super.selectImports(WebApplicationType.SERVLET); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java index 380a76a848a..d9565b564c8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java @@ -80,12 +80,14 @@ final class SessionStoreMappings { return configurationClass.getName(); } - static StoreType getType(String configurationClassName) { + static StoreType getType(WebApplicationType webApplicationType, + String configurationClassName) { for (Map.Entry>> storeEntry : MAPPINGS .entrySet()) { for (Map.Entry> entry : storeEntry.getValue() .entrySet()) { - if (entry.getValue().getName().equals(configurationClassName)) { + if (entry.getKey() == webApplicationType + && entry.getValue().getName().equals(configurationClassName)) { return storeEntry.getKey(); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java index 29ca0da1128..a429594990f 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/SmartImportCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java index d5392997d51..be0bb5163ef 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java index eff020d3315..d5e2ce5842c 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -178,15 +178,20 @@ public class JsonTestersAutoConfiguration { } private void processField(Object bean, Field field) { - if (AbstractJsonMarshalTester.class.isAssignableFrom(field.getType()) - || BasicJsonTester.class.isAssignableFrom(field.getType())) { - ResolvableType type = ResolvableType.forField(field).getGeneric(); - ReflectionUtils.makeAccessible(field); - Object tester = ReflectionUtils.getField(field, bean); - if (tester != null) { - ReflectionTestUtils.invokeMethod(tester, "initialize", - bean.getClass(), type); - } + if (AbstractJsonMarshalTester.class.isAssignableFrom(field.getType())) { + initializeTester(bean, field, bean.getClass(), + ResolvableType.forField(field).getGeneric()); + } + else if (BasicJsonTester.class.isAssignableFrom(field.getType())) { + initializeTester(bean, field, bean.getClass()); + } + } + + private void initializeTester(Object bean, Field field, Object... args) { + ReflectionUtils.makeAccessible(field); + Object tester = ReflectionUtils.getField(field, bean); + if (tester != null) { + ReflectionTestUtils.invokeMethod(tester, "initialize", args); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java index 4909f174ad0..187d834a075 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -20,7 +20,6 @@ import java.io.File; import java.io.InputStream; import java.nio.charset.Charset; -import org.springframework.core.ResolvableType; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -80,10 +79,9 @@ public class BasicJsonTester { * UTF-8. * @param resourceLoadClass the source class used when loading relative classpath * resources - * @param type the type under test */ - protected final void initialize(Class resourceLoadClass, ResolvableType type) { - this.initialize(resourceLoadClass, null, type); + protected final void initialize(Class resourceLoadClass) { + this.initialize(resourceLoadClass, null); } /** @@ -91,11 +89,9 @@ public class BasicJsonTester { * @param resourceLoadClass the source class used when loading relative classpath * resources * @param charset the charset used when loading relative classpath resources - * @param type the type under test * @since 1.4.1 */ - protected final void initialize(Class resourceLoadClass, Charset charset, - ResolvableType type) { + protected final void initialize(Class resourceLoadClass, Charset charset) { if (this.loader == null) { this.loader = new JsonLoader(resourceLoadClass, charset); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java index d756f452df1..73d77449785 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -97,7 +97,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda private Map beanNameRegistry = new HashMap<>(); - private Map fieldRegistry = new HashMap<>(); + private Map fieldRegistry = new HashMap<>(); private Map spies = new HashMap<>(); @@ -194,7 +194,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda this.mockitoBeans.add(mock); this.beanNameRegistry.put(definition, beanName); if (field != null) { - this.fieldRegistry.put(field, new RegisteredField(definition, beanName)); + this.fieldRegistry.put(field, beanName); } } @@ -347,7 +347,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda this.spies.put(beanName, definition); this.beanNameRegistry.put(definition, beanName); if (field != null) { - this.fieldRegistry.put(field, new RegisteredField(definition, beanName)); + this.fieldRegistry.put(field, beanName); } } @@ -370,9 +370,9 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda } private void postProcessField(Object bean, Field field) { - RegisteredField registered = this.fieldRegistry.get(field); - if (registered != null && StringUtils.hasLength(registered.getBeanName())) { - inject(field, bean, registered.getBeanName()); + String beanName = this.fieldRegistry.get(field); + if (StringUtils.hasText(beanName)) { + inject(field, bean, beanName); } } @@ -511,28 +511,4 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda } - /** - * A registered field item. - */ - private static class RegisteredField { - - private final Definition definition; - - private final String beanName; - - RegisteredField(Definition definition, String beanName) { - this.definition = definition; - this.beanName = beanName; - } - - public Definition getDefinition() { - return this.definition; - } - - public String getBeanName() { - return this.beanName; - } - - } - } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateTestContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateTestContextCustomizer.java index 205029345a2..7ba5742537c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateTestContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateTestContextCustomizer.java @@ -62,12 +62,11 @@ class TestRestTemplateTestContextCustomizer implements ContextCustomizer { private void registerTestRestTemplate(ConfigurableApplicationContext context) { ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); if (beanFactory instanceof BeanDefinitionRegistry) { - registerTestRestTemplate(context, (BeanDefinitionRegistry) context); + registerTestRestTemplate((BeanDefinitionRegistry) context); } } - private void registerTestRestTemplate(ConfigurableApplicationContext context, - BeanDefinitionRegistry registry) { + private void registerTestRestTemplate(BeanDefinitionRegistry registry) { RootBeanDefinition definition = new RootBeanDefinition( TestRestTemplateRegistrar.class); definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index 0085b2fe344..f402dff0c30 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ArrayBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ArrayBinder.java index eeecc65a73d..70dac910326 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ArrayBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ArrayBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -41,8 +41,7 @@ class ArrayBinder extends IndexedElementsBinder { IndexedCollectionSupplier collection = new IndexedCollectionSupplier( ArrayList::new); ResolvableType elementType = target.getType().getComponentType(); - bindIndexed(name, target, elementBinder, collection, target.getType(), - elementType); + bindIndexed(name, elementBinder, collection, target.getType(), elementType); if (collection.wasSupplied()) { List list = (List) collection.get(); Object array = Array.newInstance(elementType.resolve(), list.size()); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index 9750aad885f..625cfbdbc48 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -295,7 +295,8 @@ public class Binder { .filter(Objects::nonNull).findFirst().orElse(null); } - private Object bindProperty(Bindable target, Context context, ConfigurationProperty property) { + private Object bindProperty(Bindable target, Context context, + ConfigurationProperty property) { context.setConfigurationProperty(property); Object result = property.getValue(); result = this.placeholdersResolver.resolvePlaceholders(result); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java index 9e45f5c7895..dd52f16201b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -45,7 +45,7 @@ class CollectionBinder extends IndexedElementsBinder> { ResolvableType elementType = target.getType().asCollection().getGeneric(); ResolvableType aggregateType = ResolvableType.forClassWithGenerics(List.class, target.getType().asCollection().getGenerics()); - bindIndexed(name, target, elementBinder, collection, aggregateType, elementType); + bindIndexed(name, elementBinder, collection, aggregateType, elementType); if (collection.wasSupplied()) { return collection.get(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java index 2710493c038..8b568266583 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -53,7 +53,7 @@ abstract class IndexedElementsBinder extends AggregateBinder { return source == null || source instanceof IterableConfigurationPropertySource; } - protected final void bindIndexed(ConfigurationPropertyName name, Bindable target, + protected final void bindIndexed(ConfigurationPropertyName name, AggregateElementBinder elementBinder, IndexedCollectionSupplier collection, ResolvableType aggregateType, ResolvableType elementType) { for (ConfigurationPropertySource source : getContext().getSources()) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java index 71141454559..efdd118608a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java index 0e13935ad89..3f74389dc46 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatErrorPage.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java index 04f6061c7cf..3aaa311f45c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -72,8 +72,7 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { SSLContext sslContext = SSLContext.getInstance(this.ssl.getProtocol()); sslContext.init(getKeyManagers(this.ssl, this.sslStoreProvider), getTrustManagers(this.ssl, this.sslStoreProvider), null); - builder.addHttpsListener(this.port, getListenAddress(), - sslContext); + builder.addHttpsListener(this.port, getListenAddress(), sslContext); builder.setSocketOption(Options.SSL_CLIENT_AUTH_MODE, getSslClientAuthMode(this.ssl)); if (this.ssl.getEnabledProtocols() != null) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java index ca5cdac9412..4eb37be3e0e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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,10 +48,9 @@ abstract class ServletComponentHandler { return this.typeFilter; } - protected String[] extractUrlPatterns(String attribute, - Map attributes) { + protected String[] extractUrlPatterns(Map attributes) { String[] value = (String[]) attributes.get("value"); - String[] urlPatterns = (String[]) attributes.get(attribute); + String[] urlPatterns = (String[]) attributes.get("urlPatterns"); if (urlPatterns.length > 0) { Assert.state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive."); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebFilterHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebFilterHandler.java index e8ed855ce7f..ccdfac65bcf 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebFilterHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebFilterHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -53,8 +53,7 @@ class WebFilterHandler extends ServletComponentHandler { String name = determineName(attributes, beanDefinition); builder.addPropertyValue("name", name); builder.addPropertyValue("servletNames", attributes.get("servletNames")); - builder.addPropertyValue("urlPatterns", - extractUrlPatterns("urlPatterns", attributes)); + builder.addPropertyValue("urlPatterns", extractUrlPatterns(attributes)); registry.registerBeanDefinition(name, builder.getBeanDefinition()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebServletHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebServletHandler.java index edad3ffb7fe..f50f0b8e209 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebServletHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/WebServletHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -51,8 +51,7 @@ class WebServletHandler extends ServletComponentHandler { String name = determineName(attributes, beanDefinition); builder.addPropertyValue("name", name); builder.addPropertyValue("servlet", beanDefinition); - builder.addPropertyValue("urlMappings", - extractUrlPatterns("urlPatterns", attributes)); + builder.addPropertyValue("urlMappings", extractUrlPatterns(attributes)); builder.addPropertyValue("multipartConfig", determineMultipartConfig(beanDefinition)); registry.registerBeanDefinition(name, builder.getBeanDefinition());