From 2c1e81adf085f35c09f778a728a878c7a96e43fd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 26 Dec 2019 10:42:40 +0100 Subject: [PATCH] Polish --- .../OnEndpointElementCondition.java | 3 ++- .../ConfigurationPropertiesReportEndpoint.java | 2 +- .../endpoint/web/PathMappedEndpoints.java | 12 +++++------- .../HealthWebEndpointResponseMapper.java | 2 +- .../autoconfigure/amqp/RabbitProperties.java | 2 +- .../redis/RedisConnectionConfiguration.java | 2 +- .../http/HttpMessageConverters.java | 4 ++-- .../ArtemisConnectionFactoryFactory.java | 10 +++++----- .../autoconfigure/ldap/LdapProperties.java | 2 +- .../TomcatWebServerFactoryCustomizer.java | 18 ++++++++---------- .../UndertowWebServerFactoryCustomizer.java | 15 ++++++--------- .../cli/command/archive/ArchiveCommand.java | 3 +-- .../boot/cli/command/core/HintCommand.java | 5 ++--- .../devtools/livereload/LiveReloadServer.java | 2 +- .../migrator/PropertiesMigrationReporter.java | 18 ++++++++---------- .../AbstractApplicationContextRunner.java | 15 ++++++--------- .../mock/mockito/MockitoPostProcessor.java | 3 ++- ...nfigurationMetadataAnnotationProcessor.java | 4 ++-- .../boot/loader/ExecutableArchiveLauncher.java | 2 +- .../boot/loader/PropertiesLauncher.java | 6 +++--- .../ModifiedClassPathClassLoader.java | 3 +-- .../classpath/ModifiedClassPathExtension.java | 5 ++--- .../testsupport/compiler/TestCompiler.java | 3 ++- .../jetty/JettyServletWebServerFactory.java | 2 +- 24 files changed, 65 insertions(+), 78 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java index 0ad2e1d9ef2..e1634475bbc 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java @@ -69,7 +69,8 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition { } protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) { - boolean match = Boolean.valueOf(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true")); + boolean match = Boolean + .parseBoolean(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true")); return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType) .because(this.prefix + "defaults.enabled is considered " + match)); } 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 61068e3059b..3c3b5be3be8 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 @@ -186,7 +186,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext * @param prefix the prefix * @return the serialized instance */ - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) private Map safeSerialize(ObjectMapper mapper, Object bean, String prefix) { try { return new HashMap<>(mapper.convertValue(bean, Map.class)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java index 6a98053496b..7da9f121460 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java @@ -65,13 +65,11 @@ public class PathMappedEndpoints implements Iterable { private Map getEndpoints(Collection> suppliers) { Map endpoints = new LinkedHashMap<>(); - suppliers.forEach((supplier) -> { - supplier.getEndpoints().forEach((endpoint) -> { - if (endpoint instanceof PathMappedEndpoint) { - endpoints.put(endpoint.getEndpointId(), (PathMappedEndpoint) endpoint); - } - }); - }); + suppliers.forEach((supplier) -> supplier.getEndpoints().forEach((endpoint) -> { + if (endpoint instanceof PathMappedEndpoint) { + endpoints.put(endpoint.getEndpointId(), (PathMappedEndpoint) endpoint); + } + })); return Collections.unmodifiableMap(endpoints); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java index 5d61550618e..a6e8ec91d6d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java @@ -99,7 +99,7 @@ public class HealthWebEndpointResponseMapper { } private WebEndpointResponse createWebEndpointResponse(Health health) { - Integer status = this.statusHttpMapper.mapStatus(health.getStatus()); + int status = this.statusHttpMapper.mapStatus(health.getStatus()); return new WebEndpointResponse<>(health, status); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 6eed4a93693..96f9c97fb33 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -1059,7 +1059,7 @@ public class RabbitProperties { } else { this.host = input.substring(0, portIndex); - this.port = Integer.valueOf(input.substring(portIndex + 1)); + this.port = Integer.parseInt(input.substring(portIndex + 1)); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisConnectionConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisConnectionConfiguration.java index 9d94019acf9..ec184be6953 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisConnectionConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisConnectionConfiguration.java @@ -120,7 +120,7 @@ abstract class RedisConnectionConfiguration { try { String[] parts = StringUtils.split(node, ":"); Assert.state(parts.length == 2, "Must be defined as 'host:port'"); - nodes.add(new RedisNode(parts[0], Integer.valueOf(parts[1]))); + nodes.add(new RedisNode(parts[0], Integer.parseInt(parts[1]))); } catch (RuntimeException ex) { throw new IllegalStateException("Invalid redis sentinel property '" + node + "'", ex); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java index b6bd8be3384..d7e60781ef8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java @@ -44,8 +44,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp * needed, otherwise default converters will be used. *

* NOTE: The default converters used are the same as standard Spring MVC (see - * {@link WebMvcConfigurationSupport#getMessageConverters} with some slight re-ordering to - * put XML converters at the back of the list. + * {@link WebMvcConfigurationSupport}) with some slight re-ordering to put XML converters + * at the back of the list. * * @author Dave Syer * @author Phillip Webb diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java index fd0a76c1fa3..e8b9979189f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java @@ -68,10 +68,10 @@ class ArtemisConnectionFactoryFactory { } private void startEmbeddedJms() { - for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) { - if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) { + for (String embeddedJmsClass : EMBEDDED_JMS_CLASSES) { + if (ClassUtils.isPresent(embeddedJmsClass, null)) { try { - this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i])); + this.beanFactory.getBeansOfType(Class.forName(embeddedJmsClass)); } catch (Exception ex) { // Ignore @@ -103,8 +103,8 @@ class ArtemisConnectionFactoryFactory { } private boolean isEmbeddedJmsClassPresent() { - for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) { - if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) { + for (String embeddedJmsClass : EMBEDDED_JMS_CLASSES) { + if (ClassUtils.isPresent(embeddedJmsClass, null)) { return true; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java index db02437662c..3434507a687 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java @@ -120,7 +120,7 @@ public class LdapProperties { Assert.notNull(environment, "Environment must not be null"); String localPort = environment.getProperty("local.ldap.port"); if (localPort != null) { - return Integer.valueOf(localPort); + return Integer.parseInt(localPort); } return DEFAULT_PORT; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java index 8fb4ba636ba..1832ed43839 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java @@ -282,17 +282,15 @@ public class TomcatWebServerFactoryCustomizer private void customizeStaticResources(ConfigurableTomcatWebServerFactory factory) { ServerProperties.Tomcat.Resource resource = this.serverProperties.getTomcat().getResource(); - factory.addContextCustomizers((context) -> { - context.addLifecycleListener((event) -> { - if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { - context.getResources().setCachingAllowed(resource.isAllowCaching()); - if (resource.getCacheTtl() != null) { - long ttl = resource.getCacheTtl().toMillis(); - context.getResources().setCacheTtl(ttl); - } + factory.addContextCustomizers((context) -> context.addLifecycleListener((event) -> { + if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { + context.getResources().setCachingAllowed(resource.isAllowCaching()); + if (resource.getCacheTtl() != null) { + long ttl = resource.getCacheTtl().toMillis(); + context.getResources().setCacheTtl(ttl); } - }); - }); + } + })); } private void customizeErrorReportValve(ErrorProperties error, ConfigurableTomcatWebServerFactory factory) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java index c5626845782..24dbd3b96dc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java @@ -168,16 +168,13 @@ public class UndertowWebServerFactoryCustomizer return (value) -> this.factory.addBuilderCustomizers((builder) -> builder.setSocketOption(option, value)); } - @SuppressWarnings("unchecked") Consumer> forEach(Function, Consumer> function) { - return (map) -> { - map.forEach((key, value) -> { - Option option = (Option) NAME_LOOKUP.get(getCanonicalName(key)); - Assert.state(option != null, "Unable to find '" + key + "' in UndertowOptions"); - T parsed = option.parseValue(value, getClass().getClassLoader()); - function.apply(option).accept(parsed); - }); - }; + return (map) -> map.forEach((key, value) -> { + Option option = (Option) NAME_LOOKUP.get(getCanonicalName(key)); + Assert.state(option != null, "Unable to find '" + key + "' in UndertowOptions"); + T parsed = option.parseValue(value, getClass().getClassLoader()); + function.apply(option).accept(parsed); + }); } private static String getCanonicalName(String name) { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java index febc69990da..3ab71247129 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java @@ -18,7 +18,6 @@ package org.springframework.boot.cli.command.archive; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -175,7 +174,7 @@ abstract class ArchiveCommand extends OptionParsingCommand { } private void writeJar(File file, Class[] compiledClasses, List classpathEntries, - List dependencies) throws FileNotFoundException, IOException, URISyntaxException { + List dependencies) throws IOException, URISyntaxException { final List libraries; try (JarWriter writer = new JarWriter(file)) { addManifest(writer, compiledClasses); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java index 08ce4baa991..dd9f65b2248 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java @@ -17,6 +17,7 @@ package org.springframework.boot.cli.command.core; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -48,9 +49,7 @@ public class HintCommand extends AbstractCommand { try { int index = (args.length != 0) ? Integer.parseInt(args[0]) - 1 : 0; List arguments = new ArrayList<>(args.length); - for (int i = 2; i < args.length; i++) { - arguments.add(args[i]); - } + arguments.addAll(Arrays.asList(args).subList(2, args.length)); String starting = ""; if (index < arguments.size()) { starting = arguments.remove(index); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java index 8c79a36c8de..773fcabc87f 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java @@ -283,7 +283,7 @@ public class LiveReloadServer { } } - private void runConnection(Connection connection) throws IOException, Exception { + private void runConnection(Connection connection) throws Exception { try { addConnection(connection); connection.run(); diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java index d60dbbf431c..fcda7c60575 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java @@ -98,16 +98,14 @@ class PropertiesMigrationReporter { MultiValueMap result = new LinkedMultiValueMap<>(); List candidates = this.allProperties.values().stream().filter(filter) .collect(Collectors.toList()); - getPropertySourcesAsMap().forEach((name, source) -> { - candidates.forEach((metadata) -> { - ConfigurationProperty configurationProperty = source - .getConfigurationProperty(ConfigurationPropertyName.of(metadata.getId())); - if (configurationProperty != null) { - result.add(name, new PropertyMigration(configurationProperty, metadata, - determineReplacementMetadata(metadata))); - } - }); - }); + getPropertySourcesAsMap().forEach((name, source) -> candidates.forEach((metadata) -> { + ConfigurationProperty configurationProperty = source + .getConfigurationProperty(ConfigurationPropertyName.of(metadata.getId())); + if (configurationProperty != null) { + result.add(name, + new PropertyMigration(configurationProperty, metadata, determineReplacementMetadata(metadata))); + } + })); return result; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java index 8e43214ec26..0c116a86a85 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java @@ -351,16 +351,13 @@ public abstract class AbstractApplicationContextRunner consumer) { - withContextClassLoader(this.classLoader, () -> { - this.systemProperties.applyToSystemProperties(() -> { - try (A context = createAssertableContext()) { - accept(consumer, context); - } - return null; - }); - }); + withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> { + try (A context = createAssertableContext()) { + accept(consumer, context); + } + return null; + })); return (SELF) this; } 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 41b5715a5cc..44f51fc7f69 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 @@ -20,6 +20,7 @@ import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -307,7 +308,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda if (primaryBeanName != null) { throw new NoUniqueBeanDefinitionException(type.resolve(), candidateBeanNames.size(), "more than one 'primary' bean found among candidates: " - + Arrays.asList(candidateBeanNames)); + + Collections.singletonList(candidateBeanNames)); } primaryBeanName = candidateBeanName; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index e619f75bb7d..30b4d34eae6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -181,10 +181,10 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor if (annotation != null) { String prefix = getPrefix(annotation); if (element instanceof TypeElement) { - processAnnotatedTypeElement(prefix, (TypeElement) element, new Stack()); + processAnnotatedTypeElement(prefix, (TypeElement) element, new Stack<>()); } else if (element instanceof ExecutableElement) { - processExecutableElement(prefix, (ExecutableElement) element, new Stack()); + processExecutableElement(prefix, (ExecutableElement) element, new Stack<>()); } } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java index 79e322a9d43..307211a200c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java @@ -74,7 +74,7 @@ public abstract class ExecutableArchiveLauncher extends Launcher { } private Iterator applyClassPathArchivePostProcessing(Iterator archives) throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); while (archives.hasNext()) { list.add(archives.next()); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index a7f8c38cc85..a6dff5ae179 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -167,7 +167,7 @@ public class PropertiesLauncher extends Launcher { } } - private void initializeProperties() throws Exception, IOException { + private void initializeProperties() throws Exception { List configs = new ArrayList<>(); if (getProperty(CONFIG_LOCATION) != null) { configs.add(getProperty(CONFIG_LOCATION)); @@ -195,7 +195,7 @@ public class PropertiesLauncher extends Launcher { } } - private void loadResource(InputStream resource) throws IOException, Exception { + private void loadResource(InputStream resource) throws Exception { this.properties.load(resource); for (Object key : Collections.list(this.properties.propertyNames())) { String text = this.properties.getProperty((String) key); @@ -591,7 +591,7 @@ public class PropertiesLauncher extends Launcher { } private List asList(Iterator iterator) { - List list = new ArrayList(); + List list = new ArrayList<>(); while (iterator.hasNext()) { list.add(iterator.next()); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java index ec9ef0f6cff..588ac70fc9d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java @@ -172,9 +172,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader { MergedAnnotations annotations = MergedAnnotations.from(testClass, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY); ClassPathEntryFilter filter = new ClassPathEntryFilter(annotations.get(ClassPathExclusions.class)); - List processedUrls = new ArrayList<>(); List additionalUrls = getAdditionalUrls(annotations.get(ClassPathOverrides.class)); - processedUrls.addAll(additionalUrls); + List processedUrls = new ArrayList<>(additionalUrls); for (URL url : urls) { if (!filter.isExcluded(url)) { processedUrls.add(url); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java index 9099ee73855..38e5f17faf5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java @@ -81,7 +81,7 @@ class ModifiedClassPathExtension implements InvocationInterceptor { } private void runTestWithModifiedClassPath(ReflectiveInvocationContext invocationContext, - ExtensionContext extensionContext) throws ClassNotFoundException, Throwable { + ExtensionContext extensionContext) throws Throwable { Class testClass = extensionContext.getRequiredTestClass(); Method testMethod = invocationContext.getExecutable(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); @@ -95,8 +95,7 @@ class ModifiedClassPathExtension implements InvocationInterceptor { } } - private void runTest(ClassLoader classLoader, String testClassName, String testMethodName) - throws ClassNotFoundException, Throwable { + private void runTest(ClassLoader classLoader, String testClassName, String testMethodName) throws Throwable { Class testClass = classLoader.loadClass(testClassName); Method testMethod = findMethod(testClass, testMethodName); LauncherDiscoveryRequest request = new LauncherDiscoveryRequestBuilder(classLoader) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java index 3bf0002f00f..266d550166f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import javax.annotation.processing.Processor; import javax.tools.JavaCompiler; @@ -59,7 +60,7 @@ public class TestCompiler { this.fileManager = compiler.getStandardFileManager(null, null, null); this.outputLocation = outputLocation; this.outputLocation.mkdirs(); - Iterable temp = Arrays.asList(this.outputLocation); + Iterable temp = Collections.singletonList(this.outputLocation); this.fileManager.setLocation(StandardLocation.CLASS_OUTPUT, temp); this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, temp); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index 63445ec0d21..b17d9601b32 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -521,7 +521,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor } @Override - public Resource addPath(String path) throws IOException, MalformedURLException { + public Resource addPath(String path) throws IOException { if (path.startsWith("/org/springframework/boot")) { return null; }