Commit 9af6b342 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 45613f8c
...@@ -398,9 +398,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext ...@@ -398,9 +398,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
&& Character.isUpperCase(propertyName.charAt(1))) { && Character.isUpperCase(propertyName.charAt(1))) {
return propertyName; return propertyName;
} }
else { return StringUtils.capitalize(propertyName);
return StringUtils.capitalize(propertyName);
}
} }
} }
......
...@@ -30,7 +30,6 @@ import org.springframework.core.env.Environment; ...@@ -30,7 +30,6 @@ import org.springframework.core.env.Environment;
* default the properties must be present in the {@link Environment} and * default the properties must be present in the {@link Environment} and
* <strong>not</strong> equal to {@code false}. The {@link #havingValue()} and * <strong>not</strong> equal to {@code false}. The {@link #havingValue()} and
* {@link #matchIfMissing()} attributes allow further customizations. * {@link #matchIfMissing()} attributes allow further customizations.
*
* <p> * <p>
* The {@link #havingValue} attribute can be used to specify the value that the property * 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 * should have. The table below shows when a condition matches according to the property
...@@ -66,12 +65,10 @@ import org.springframework.core.env.Environment; ...@@ -66,12 +65,10 @@ import org.springframework.core.env.Environment;
* <td>yes</td> * <td>yes</td>
* </tr> * </tr>
* </table> * </table>
*
* <p> * <p>
* If the property is not contained in the {@link Environment} at all, the * If the property is not contained in the {@link Environment} at all, the
* {@link #matchIfMissing()} attribute is consulted. By default missing attributes do not * {@link #matchIfMissing()} attribute is consulted. By default missing attributes do not
* match. * match.
*
* <p> * <p>
* This condition cannot be reliably used for matching collection properties. For example, * This condition cannot be reliably used for matching collection properties. For example,
* in the following configuration, the condition matches if {@code spring.example.values} * in the following configuration, the condition matches if {@code spring.example.values}
......
...@@ -36,7 +36,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; ...@@ -36,7 +36,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
*/ */
public class OnPropertyListCondition extends SpringBootCondition { public class OnPropertyListCondition extends SpringBootCondition {
private static final Bindable<List<String>> SIMPLE_LIST = Bindable private static final Bindable<List<String>> STRING_LIST = Bindable
.listOf(String.class); .listOf(String.class);
private final String propertyName; private final String propertyName;
...@@ -59,7 +59,7 @@ public class OnPropertyListCondition extends SpringBootCondition { ...@@ -59,7 +59,7 @@ public class OnPropertyListCondition extends SpringBootCondition {
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
BindResult<?> property = Binder.get(context.getEnvironment()) BindResult<?> property = Binder.get(context.getEnvironment())
.bind(this.propertyName, SIMPLE_LIST); .bind(this.propertyName, STRING_LIST);
ConditionMessage.Builder messageBuilder = this.messageBuilder.get(); ConditionMessage.Builder messageBuilder = this.messageBuilder.get();
if (property.isBound()) { if (property.isBound()) {
return ConditionOutcome return ConditionOutcome
......
...@@ -65,10 +65,8 @@ class OnWebApplicationCondition extends SpringBootCondition { ...@@ -65,10 +65,8 @@ class OnWebApplicationCondition extends SpringBootCondition {
switch (deduceType(metadata)) { switch (deduceType(metadata)) {
case SERVLET: case SERVLET:
return isServletWebApplication(context); return isServletWebApplication(context);
case REACTIVE: case REACTIVE:
return isReactiveWebApplication(context); return isReactiveWebApplication(context);
default: default:
return isAnyWebApplication(context, required); return isAnyWebApplication(context, required);
} }
......
...@@ -24,6 +24,7 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector; ...@@ -24,6 +24,7 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
* used for Spring MVC applications. * used for Spring MVC applications.
* *
* @author Madhura Bhave * @author Madhura Bhave
* @since 2.0.5
*/ */
public class MvcRequestMatcherProvider implements RequestMatcherProvider { public class MvcRequestMatcherProvider implements RequestMatcherProvider {
......
...@@ -27,6 +27,11 @@ import org.springframework.security.web.util.matcher.RequestMatcher; ...@@ -27,6 +27,11 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
@FunctionalInterface @FunctionalInterface
public interface RequestMatcherProvider { 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); RequestMatcher getRequestMatcher(String pattern);
} }
...@@ -149,6 +149,11 @@ final class JavaPluginAction implements PluginApplicationAction { ...@@ -149,6 +149,11 @@ final class JavaPluginAction implements PluginApplicationAction {
compile.doFirst(new AdditionalMetadataLocationsConfigurer()); 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<Task> { private static class AdditionalMetadataLocationsConfigurer implements Action<Task> {
@Override @Override
......
...@@ -42,7 +42,7 @@ final class EnvironmentConverter { ...@@ -42,7 +42,7 @@ final class EnvironmentConverter {
private static final Set<String> SERVLET_ENVIRONMENT_SOURCE_NAMES; private static final Set<String> SERVLET_ENVIRONMENT_SOURCE_NAMES;
static { static {
final Set<String> names = new HashSet<>(); Set<String> names = new HashSet<>();
names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME);
names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME);
names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME);
...@@ -65,20 +65,20 @@ final class EnvironmentConverter { ...@@ -65,20 +65,20 @@ final class EnvironmentConverter {
* type. If the environment is already of the same type, no conversion is performed * type. If the environment is already of the same type, no conversion is performed
* and it is returned unchanged. * and it is returned unchanged.
* @param environment the Environment to convert * @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 * @return the converted Environment
*/ */
StandardEnvironment convertEnvironmentIfNecessary(ConfigurableEnvironment environment, StandardEnvironment convertEnvironmentIfNecessary(ConfigurableEnvironment environment,
Class<? extends StandardEnvironment> conversionType) { Class<? extends StandardEnvironment> type) {
if (conversionType.equals(environment.getClass())) { if (type.equals(environment.getClass())) {
return (StandardEnvironment) environment; return (StandardEnvironment) environment;
} }
return convertEnvironment(environment, conversionType); return convertEnvironment(environment, type);
} }
private StandardEnvironment convertEnvironment(ConfigurableEnvironment environment, private StandardEnvironment convertEnvironment(ConfigurableEnvironment environment,
Class<? extends StandardEnvironment> conversionType) { Class<? extends StandardEnvironment> type) {
StandardEnvironment result = createEnvironment(conversionType); StandardEnvironment result = createEnvironment(type);
result.setActiveProfiles(environment.getActiveProfiles()); result.setActiveProfiles(environment.getActiveProfiles());
result.setConversionService(environment.getConversionService()); result.setConversionService(environment.getConversionService());
copyPropertySources(environment, result); copyPropertySources(environment, result);
...@@ -86,9 +86,9 @@ final class EnvironmentConverter { ...@@ -86,9 +86,9 @@ final class EnvironmentConverter {
} }
private StandardEnvironment createEnvironment( private StandardEnvironment createEnvironment(
Class<? extends StandardEnvironment> conversionType) { Class<? extends StandardEnvironment> type) {
try { try {
return conversionType.newInstance(); return type.newInstance();
} }
catch (Exception ex) { catch (Exception ex) {
return new StandardEnvironment(); return new StandardEnvironment();
......
...@@ -463,15 +463,12 @@ public class ConfigFileApplicationListener ...@@ -463,15 +463,12 @@ public class ConfigFileApplicationListener
} }
} }
} }
Set<String> processedExtensions = new HashSet<>(); Set<String> processed = new HashSet<>();
for (PropertySourceLoader loader : this.propertySourceLoaders) { for (PropertySourceLoader loader : this.propertySourceLoaders) {
for (String fileExtension : loader.getFileExtensions()) { for (String fileExtension : loader.getFileExtensions()) {
if (!processedExtensions.contains(fileExtension)) { if (processed.add(fileExtension)) {
processedExtensions.add(fileExtension); loadForFileExtension(loader, location + name, "." + fileExtension,
String prefix = location + name; profile, filterFactory, consumer);
fileExtension = "." + fileExtension;
loadForFileExtension(loader, prefix, fileExtension, profile,
filterFactory, consumer);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment