Skip to content

Commit 825dd0a

Browse files
committed
Merge branch '1.3.x'
2 parents 49f28b7 + 3b52909 commit 825dd0a

File tree

8 files changed

+68
-17
lines changed

8 files changed

+68
-17
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public MetricFilterAutoConfiguration(CounterService counterService,
6464
}
6565

6666
@Bean
67-
public MetricsFilter metricFilter() {
67+
public MetricsFilter metricsFilter() {
6868
return new MetricsFilter(this.counterService, this.gaugeService, this.properties);
6969
}
7070

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -161,27 +161,63 @@ public List<ConditionOutcome> getMatchOutcomes() {
161161
for (Map.Entry<AnnotationMetadata, List<Condition>> entry : this.memberConditions
162162
.entrySet()) {
163163
AnnotationMetadata metadata = entry.getKey();
164-
for (Condition condition : entry.getValue()) {
165-
outcomes.add(getConditionOutcome(metadata, condition));
166-
}
164+
List<Condition> conditions = entry.getValue();
165+
outcomes.add(new MemberOutcomes(this.context, metadata, conditions)
166+
.getUltimateOutcome());
167167
}
168168
return Collections.unmodifiableList(outcomes);
169169
}
170170

171+
}
172+
173+
private static class MemberOutcomes {
174+
175+
private final ConditionContext context;
176+
177+
private final AnnotationMetadata metadata;
178+
179+
private final List<ConditionOutcome> outcomes;
180+
181+
MemberOutcomes(ConditionContext context, AnnotationMetadata metadata,
182+
List<Condition> conditions) {
183+
this.context = context;
184+
this.metadata = metadata;
185+
this.outcomes = new ArrayList<ConditionOutcome>(conditions.size());
186+
for (Condition condition : conditions) {
187+
this.outcomes.add(getConditionOutcome(metadata, condition));
188+
}
189+
}
190+
171191
private ConditionOutcome getConditionOutcome(AnnotationMetadata metadata,
172192
Condition condition) {
173-
String className = ClassUtils.getShortName(metadata.getClassName());
174193
if (condition instanceof SpringBootCondition) {
175-
ConditionOutcome outcome = ((SpringBootCondition) condition)
176-
.getMatchOutcome(this.context, metadata);
177-
ConditionMessage message = outcome.getConditionMessage()
178-
.append("on member " + className);
179-
return new ConditionOutcome(outcome.isMatch(), message);
194+
return ((SpringBootCondition) condition).getMatchOutcome(this.context,
195+
metadata);
196+
}
197+
return new ConditionOutcome(condition.matches(this.context, metadata),
198+
(ConditionMessage) null);
199+
}
200+
201+
public ConditionOutcome getUltimateOutcome() {
202+
ConditionMessage.Builder message = ConditionMessage
203+
.forCondition("NestedCondition on "
204+
+ ClassUtils.getShortName(this.metadata.getClassName()));
205+
if (this.outcomes.size() == 1) {
206+
ConditionOutcome outcome = this.outcomes.get(0);
207+
return new ConditionOutcome(outcome.isMatch(),
208+
message.because(outcome.getMessage()));
209+
}
210+
List<ConditionOutcome> match = new ArrayList<ConditionOutcome>();
211+
List<ConditionOutcome> nonMatch = new ArrayList<ConditionOutcome>();
212+
for (ConditionOutcome outcome : this.outcomes) {
213+
(outcome.isMatch() ? match : nonMatch).add(outcome);
214+
}
215+
if (nonMatch.isEmpty()) {
216+
return ConditionOutcome
217+
.match(message.found("matching nested conditions").items(match));
180218
}
181-
boolean matches = condition.matches(this.context, metadata);
182-
return new ConditionOutcome(matches,
183-
ConditionMessage.forCondition("NestedCondition")
184-
.because("nested on member " + className));
219+
return ConditionOutcome.noMatch(
220+
message.found("non-matching nested conditions").items(nonMatch));
185221
}
186222

187223
}

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
132132

133133
@Bean
134134
@ConditionalOnMissingBean(HttpPutFormContentFilter.class)
135+
@ConditionalOnProperty(prefix = "spring.mvc.formcontent.putfilter", name = "enabled", matchIfMissing = true)
135136
public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
136137
return new OrderedHttpPutFormContentFilter();
137138
}

spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@
279279
"description": "Enable resolution of favicon.ico.",
280280
"defaultValue": true
281281
},
282+
{
283+
"name": "spring.mvc.formcontent.putfilter.enabled",
284+
"type": "java.lang.Boolean",
285+
"description": "Enable Spring's HttpPutFormContentFilter.",
286+
"defaultValue": true
287+
},
282288
{
283289
"name": "spring.rabbitmq.dynamic",
284290
"type": "java.lang.Boolean",

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/AnyNestedConditionTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
* Tests for {@link AnyNestedCondition}.
3131
*
3232
* @author Phillip Webb
33+
* @author Dave Syer
3334
*/
3435
public class AnyNestedConditionTests {
3536

3637
@Test
3738
public void neither() throws Exception {
38-
AnnotationConfigApplicationContext context = load(OnPropertyAorBCondition.class);
39+
AnnotationConfigApplicationContext context = load(Config.class);
3940
assertThat(context.containsBean("myBean")).isFalse();
4041
context.close();
4142
}
@@ -91,6 +92,7 @@ static class HasPropertyA {
9192

9293
}
9394

95+
@ConditionalOnExpression("true")
9496
@ConditionalOnProperty("b")
9597
static class HasPropertyB {
9698

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ public void httpPutFormContentFilterCanBeOverridden() {
504504
.hasSize(1);
505505
}
506506

507+
@Test
508+
public void httpPutFormContentFilterCanBeDisabled() throws Exception {
509+
load((Class<?>) null, "spring.mvc.formcontent.putfilter.enabled=false");
510+
assertThat(this.context.getBeansOfType(HttpPutFormContentFilter.class)).isEmpty();
511+
}
512+
507513
@Test
508514
public void customConfigurableWebBindingInitializer() {
509515
load(CustomConfigurableWebBindingInitializer.class);

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ content into your application; rather pick only the properties that you need.
341341
spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method.
342342
spring.mvc.dispatch-options-request=true # Dispatch OPTIONS requests to the FrameworkServlet doService method.
343343
spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico.
344+
spring.mvc.formcontent.putfilter.enabled=true # Enable Spring's HttpPutFormContentFilter.
344345
spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios.
345346
spring.mvc.locale= # Locale to use. By default, this locale is overridden by the "Accept-Language" header.
346347
spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved.

spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ do_start() {
147147
mkdir "$PID_FOLDER" &> /dev/null
148148
if [[ -n "$run_user" ]]; then
149149
checkPermissions || return $?
150-
chown "$run_user" "$PID_FOLDER"
151150
chown "$run_user" "$pid_file"
152151
chown "$run_user" "$log_file"
153152
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then

0 commit comments

Comments
 (0)