From 9af6b3422f4d75c7b7cc13a9b26e82ac563084e1 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 4 Sep 2018 16:18:47 -0700 Subject: [PATCH 1/2] Polish --- .../ConfigurationPropertiesReportEndpoint.java | 4 +--- .../condition/ConditionalOnProperty.java | 3 --- .../condition/OnPropertyListCondition.java | 4 ++-- .../condition/OnWebApplicationCondition.java | 2 -- .../servlet/MvcRequestMatcherProvider.java | 1 + .../servlet/RequestMatcherProvider.java | 5 +++++ .../boot/gradle/plugin/JavaPluginAction.java | 5 +++++ .../boot/EnvironmentConverter.java | 18 +++++++++--------- .../config/ConfigFileApplicationListener.java | 11 ++++------- 9 files changed, 27 insertions(+), 26 deletions(-) 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 178e4b74cd..68e9bc0578 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 @@ -398,9 +398,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext && Character.isUpperCase(propertyName.charAt(1))) { return propertyName; } - else { - return StringUtils.capitalize(propertyName); - } + return StringUtils.capitalize(propertyName); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java index 7827dac2d6..92d12994da 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java @@ -30,7 +30,6 @@ import org.springframework.core.env.Environment; * default the properties must be present in the {@link Environment} and * not equal to {@code false}. The {@link #havingValue()} and * {@link #matchIfMissing()} attributes allow further customizations. - * *

* The {@link #havingValue} attribute can be used to specify the value that the property * should have. The table below shows when a condition matches according to the property @@ -66,12 +65,10 @@ import org.springframework.core.env.Environment; * yes * * - * *

* If the property is not contained in the {@link Environment} at all, the * {@link #matchIfMissing()} attribute is consulted. By default missing attributes do not * match. - * *

* This condition cannot be reliably used for matching collection properties. For example, * in the following configuration, the condition matches if {@code spring.example.values} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyListCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyListCondition.java index db74d4ff7e..866b449312 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyListCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyListCondition.java @@ -36,7 +36,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ public class OnPropertyListCondition extends SpringBootCondition { - private static final Bindable> SIMPLE_LIST = Bindable + private static final Bindable> STRING_LIST = Bindable .listOf(String.class); private final String propertyName; @@ -59,7 +59,7 @@ public class OnPropertyListCondition extends SpringBootCondition { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { BindResult property = Binder.get(context.getEnvironment()) - .bind(this.propertyName, SIMPLE_LIST); + .bind(this.propertyName, STRING_LIST); ConditionMessage.Builder messageBuilder = this.messageBuilder.get(); if (property.isBound()) { return ConditionOutcome diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java index cf4d9610a8..19fdb00cf9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java @@ -65,10 +65,8 @@ class OnWebApplicationCondition extends SpringBootCondition { switch (deduceType(metadata)) { case SERVLET: return isServletWebApplication(context); - case REACTIVE: return isReactiveWebApplication(context); - default: return isAnyWebApplication(context, required); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/MvcRequestMatcherProvider.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/MvcRequestMatcherProvider.java index 3bf8e1cadc..2283f71655 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/MvcRequestMatcherProvider.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/MvcRequestMatcherProvider.java @@ -24,6 +24,7 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector; * used for Spring MVC applications. * * @author Madhura Bhave + * @since 2.0.5 */ public class MvcRequestMatcherProvider implements RequestMatcherProvider { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/RequestMatcherProvider.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/RequestMatcherProvider.java index 81a8f2180d..ba95491b77 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/RequestMatcherProvider.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/RequestMatcherProvider.java @@ -27,6 +27,11 @@ import org.springframework.security.web.util.matcher.RequestMatcher; @FunctionalInterface public interface RequestMatcherProvider { + /** + * Return the {@link RequestMatcher} to be used for the specified pattern. + * @param pattern the request pattern + * @return a request matcher + */ RequestMatcher getRequestMatcher(String pattern); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java index 4e86b3549c..085f06e4f2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java @@ -149,6 +149,11 @@ final class JavaPluginAction implements PluginApplicationAction { compile.doFirst(new AdditionalMetadataLocationsConfigurer()); } + /** + * Task {@link Action} to add additional meta-data locations. We need to use an + * inner-class rather than a lambda due to + * https://github.com/gradle/gradle/issues/5510. + */ private static class AdditionalMetadataLocationsConfigurer implements Action { @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java index 4482f01e82..a13b80c585 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java @@ -42,7 +42,7 @@ final class EnvironmentConverter { private static final Set SERVLET_ENVIRONMENT_SOURCE_NAMES; static { - final Set names = new HashSet<>(); + Set names = new HashSet<>(); names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME); @@ -65,20 +65,20 @@ final class EnvironmentConverter { * type. If the environment is already of the same type, no conversion is performed * and it is returned unchanged. * @param environment the Environment to convert - * @param conversionType the type to convert the Environment to + * @param type the type to convert the Environment to * @return the converted Environment */ StandardEnvironment convertEnvironmentIfNecessary(ConfigurableEnvironment environment, - Class conversionType) { - if (conversionType.equals(environment.getClass())) { + Class type) { + if (type.equals(environment.getClass())) { return (StandardEnvironment) environment; } - return convertEnvironment(environment, conversionType); + return convertEnvironment(environment, type); } private StandardEnvironment convertEnvironment(ConfigurableEnvironment environment, - Class conversionType) { - StandardEnvironment result = createEnvironment(conversionType); + Class type) { + StandardEnvironment result = createEnvironment(type); result.setActiveProfiles(environment.getActiveProfiles()); result.setConversionService(environment.getConversionService()); copyPropertySources(environment, result); @@ -86,9 +86,9 @@ final class EnvironmentConverter { } private StandardEnvironment createEnvironment( - Class conversionType) { + Class type) { try { - return conversionType.newInstance(); + return type.newInstance(); } catch (Exception ex) { return new StandardEnvironment(); 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 04daa63fc9..1814a5c27c 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 @@ -463,15 +463,12 @@ public class ConfigFileApplicationListener } } } - Set processedExtensions = new HashSet<>(); + Set processed = new HashSet<>(); for (PropertySourceLoader loader : this.propertySourceLoaders) { for (String fileExtension : loader.getFileExtensions()) { - if (!processedExtensions.contains(fileExtension)) { - processedExtensions.add(fileExtension); - String prefix = location + name; - fileExtension = "." + fileExtension; - loadForFileExtension(loader, prefix, fileExtension, profile, - filterFactory, consumer); + if (processed.add(fileExtension)) { + loadForFileExtension(loader, location + name, "." + fileExtension, + profile, filterFactory, consumer); } } } From cafff430226cd863520d828845efdf08cb619611 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 4 Sep 2018 16:19:05 -0700 Subject: [PATCH 2/2] Update copyright header of changed files --- .../web/servlet/error/AbstractErrorController.java | 2 +- .../autoconfigure/couchbase/OnBootstrapHostsConditionTests.java | 2 +- .../autoconfigure/web/format/WebConversionServiceTests.java | 2 +- .../boot/devtools/livereload/LiveReloadServerTests.java | 2 +- .../tunnel/server/SocketTargetServerConnectionTests.java | 2 +- .../java/org/springframework/boot/loader/tools/SignalUtils.java | 2 +- .../properties/bind/validation/OriginTrackedFieldError.java | 2 +- .../org/springframework/boot/EnvironmentConverterTests.java | 2 +- .../analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/AbstractErrorController.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/AbstractErrorController.java index f60d1fe33c..b396be4528 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/AbstractErrorController.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/AbstractErrorController.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-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsConditionTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsConditionTests.java index 84682a097c..d26fdb51f5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsConditionTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsConditionTests.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-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java index 0f8a97b444..afacc0ba1a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.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-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java index e0a1f461b6..8f517b135c 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.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-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/SocketTargetServerConnectionTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/SocketTargetServerConnectionTests.java index 42634ffd89..a8c806d917 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/SocketTargetServerConnectionTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/SocketTargetServerConnectionTests.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-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SignalUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SignalUtils.java index 7ad79d6a4b..2b8e97ef0e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SignalUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SignalUtils.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/validation/OriginTrackedFieldError.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/OriginTrackedFieldError.java index 79ed3bb0f3..1bedc64983 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/OriginTrackedFieldError.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/OriginTrackedFieldError.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/test/java/org/springframework/boot/EnvironmentConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/EnvironmentConverterTests.java index 73234b9b02..98f12d4343 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/EnvironmentConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/EnvironmentConverterTests.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/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java index 324be5d5d0..812f6d1c41 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.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.