Commit 825dd0a2 authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.3.x'

parents 49f28b79 3b52909f
...@@ -64,7 +64,7 @@ public class MetricFilterAutoConfiguration { ...@@ -64,7 +64,7 @@ public class MetricFilterAutoConfiguration {
} }
@Bean @Bean
public MetricsFilter metricFilter() { public MetricsFilter metricsFilter() {
return new MetricsFilter(this.counterService, this.gaugeService, this.properties); return new MetricsFilter(this.counterService, this.gaugeService, this.properties);
} }
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -161,27 +161,63 @@ abstract class AbstractNestedCondition extends SpringBootCondition ...@@ -161,27 +161,63 @@ abstract class AbstractNestedCondition extends SpringBootCondition
for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions
.entrySet()) { .entrySet()) {
AnnotationMetadata metadata = entry.getKey(); AnnotationMetadata metadata = entry.getKey();
for (Condition condition : entry.getValue()) { List<Condition> conditions = entry.getValue();
outcomes.add(getConditionOutcome(metadata, condition)); outcomes.add(new MemberOutcomes(this.context, metadata, conditions)
} .getUltimateOutcome());
} }
return Collections.unmodifiableList(outcomes); return Collections.unmodifiableList(outcomes);
} }
}
private static class MemberOutcomes {
private final ConditionContext context;
private final AnnotationMetadata metadata;
private final List<ConditionOutcome> outcomes;
MemberOutcomes(ConditionContext context, AnnotationMetadata metadata,
List<Condition> conditions) {
this.context = context;
this.metadata = metadata;
this.outcomes = new ArrayList<ConditionOutcome>(conditions.size());
for (Condition condition : conditions) {
this.outcomes.add(getConditionOutcome(metadata, condition));
}
}
private ConditionOutcome getConditionOutcome(AnnotationMetadata metadata, private ConditionOutcome getConditionOutcome(AnnotationMetadata metadata,
Condition condition) { Condition condition) {
String className = ClassUtils.getShortName(metadata.getClassName());
if (condition instanceof SpringBootCondition) { if (condition instanceof SpringBootCondition) {
ConditionOutcome outcome = ((SpringBootCondition) condition) return ((SpringBootCondition) condition).getMatchOutcome(this.context,
.getMatchOutcome(this.context, metadata); metadata);
ConditionMessage message = outcome.getConditionMessage() }
.append("on member " + className); return new ConditionOutcome(condition.matches(this.context, metadata),
return new ConditionOutcome(outcome.isMatch(), message); (ConditionMessage) null);
}
public ConditionOutcome getUltimateOutcome() {
ConditionMessage.Builder message = ConditionMessage
.forCondition("NestedCondition on "
+ ClassUtils.getShortName(this.metadata.getClassName()));
if (this.outcomes.size() == 1) {
ConditionOutcome outcome = this.outcomes.get(0);
return new ConditionOutcome(outcome.isMatch(),
message.because(outcome.getMessage()));
}
List<ConditionOutcome> match = new ArrayList<ConditionOutcome>();
List<ConditionOutcome> nonMatch = new ArrayList<ConditionOutcome>();
for (ConditionOutcome outcome : this.outcomes) {
(outcome.isMatch() ? match : nonMatch).add(outcome);
}
if (nonMatch.isEmpty()) {
return ConditionOutcome
.match(message.found("matching nested conditions").items(match));
} }
boolean matches = condition.matches(this.context, metadata); return ConditionOutcome.noMatch(
return new ConditionOutcome(matches, message.found("non-matching nested conditions").items(nonMatch));
ConditionMessage.forCondition("NestedCondition")
.because("nested on member " + className));
} }
} }
......
...@@ -132,6 +132,7 @@ public class WebMvcAutoConfiguration { ...@@ -132,6 +132,7 @@ public class WebMvcAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(HttpPutFormContentFilter.class) @ConditionalOnMissingBean(HttpPutFormContentFilter.class)
@ConditionalOnProperty(prefix = "spring.mvc.formcontent.putfilter", name = "enabled", matchIfMissing = true)
public OrderedHttpPutFormContentFilter httpPutFormContentFilter() { public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
return new OrderedHttpPutFormContentFilter(); return new OrderedHttpPutFormContentFilter();
} }
......
...@@ -279,6 +279,12 @@ ...@@ -279,6 +279,12 @@
"description": "Enable resolution of favicon.ico.", "description": "Enable resolution of favicon.ico.",
"defaultValue": true "defaultValue": true
}, },
{
"name": "spring.mvc.formcontent.putfilter.enabled",
"type": "java.lang.Boolean",
"description": "Enable Spring's HttpPutFormContentFilter.",
"defaultValue": true
},
{ {
"name": "spring.rabbitmq.dynamic", "name": "spring.rabbitmq.dynamic",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",
......
...@@ -30,12 +30,13 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -30,12 +30,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link AnyNestedCondition}. * Tests for {@link AnyNestedCondition}.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Dave Syer
*/ */
public class AnyNestedConditionTests { public class AnyNestedConditionTests {
@Test @Test
public void neither() throws Exception { public void neither() throws Exception {
AnnotationConfigApplicationContext context = load(OnPropertyAorBCondition.class); AnnotationConfigApplicationContext context = load(Config.class);
assertThat(context.containsBean("myBean")).isFalse(); assertThat(context.containsBean("myBean")).isFalse();
context.close(); context.close();
} }
...@@ -91,6 +92,7 @@ public class AnyNestedConditionTests { ...@@ -91,6 +92,7 @@ public class AnyNestedConditionTests {
} }
@ConditionalOnExpression("true")
@ConditionalOnProperty("b") @ConditionalOnProperty("b")
static class HasPropertyB { static class HasPropertyB {
......
...@@ -504,6 +504,12 @@ public class WebMvcAutoConfigurationTests { ...@@ -504,6 +504,12 @@ public class WebMvcAutoConfigurationTests {
.hasSize(1); .hasSize(1);
} }
@Test
public void httpPutFormContentFilterCanBeDisabled() throws Exception {
load((Class<?>) null, "spring.mvc.formcontent.putfilter.enabled=false");
assertThat(this.context.getBeansOfType(HttpPutFormContentFilter.class)).isEmpty();
}
@Test @Test
public void customConfigurableWebBindingInitializer() { public void customConfigurableWebBindingInitializer() {
load(CustomConfigurableWebBindingInitializer.class); load(CustomConfigurableWebBindingInitializer.class);
......
...@@ -341,6 +341,7 @@ content into your application; rather pick only the properties that you need. ...@@ -341,6 +341,7 @@ content into your application; rather pick only the properties that you need.
spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method. spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method.
spring.mvc.dispatch-options-request=true # Dispatch OPTIONS requests to the FrameworkServlet doService method. spring.mvc.dispatch-options-request=true # Dispatch OPTIONS requests to the FrameworkServlet doService method.
spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico. spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico.
spring.mvc.formcontent.putfilter.enabled=true # Enable Spring's HttpPutFormContentFilter.
spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios. spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios.
spring.mvc.locale= # Locale to use. By default, this locale is overridden by the "Accept-Language" header. spring.mvc.locale= # Locale to use. By default, this locale is overridden by the "Accept-Language" header.
spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved. spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved.
......
...@@ -147,7 +147,6 @@ do_start() { ...@@ -147,7 +147,6 @@ do_start() {
mkdir "$PID_FOLDER" &> /dev/null mkdir "$PID_FOLDER" &> /dev/null
if [[ -n "$run_user" ]]; then if [[ -n "$run_user" ]]; then
checkPermissions || return $? checkPermissions || return $?
chown "$run_user" "$PID_FOLDER"
chown "$run_user" "$pid_file" chown "$run_user" "$pid_file"
chown "$run_user" "$log_file" chown "$run_user" "$log_file"
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
......
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