Skip to content

Commit 00883a4

Browse files
committed
Merge pull request #13616 from izeye:polish-20180630
* pr/13616: Polish
2 parents 809e305 + ab6adc8 commit 00883a4

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ private void register(ServletContext servletContext,
8181
}
8282

8383
private String[] getUrlMappings(String endpointPath, String name) {
84-
return this.basePaths.stream()
85-
.map((bp) -> (bp != null ? bp + "/" + endpointPath : "/" + endpointPath))
86-
.distinct().map((p) -> {
87-
logger.info("Registered '" + p + "' to " + name);
88-
return (p.endsWith("/") ? p + "*" : p + "/*");
84+
return this.basePaths
85+
.stream().map((basePath) -> (basePath != null
86+
? basePath + "/" + endpointPath : "/" + endpointPath))
87+
.distinct().map((path) -> {
88+
logger.info("Registered '" + path + "' to " + name);
89+
return (path.endsWith("/") ? path + "*" : path + "/*");
8990
}).toArray(String[]::new);
9091
}
9192

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4242
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
4343
.get("value");
4444
expression = wrapIfNecessary(expression);
45-
String rawExpression = expression;
46-
expression = context.getEnvironment().resolvePlaceholders(expression);
4745
ConditionMessage.Builder messageBuilder = ConditionMessage
48-
.forCondition(ConditionalOnExpression.class, "(" + rawExpression + ")");
46+
.forCondition(ConditionalOnExpression.class, "(" + expression + ")");
47+
expression = context.getEnvironment().resolvePlaceholders(expression);
4948
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
5049
if (beanFactory != null) {
5150
boolean result = evaluateExpression(beanFactory, expression);

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
package org.springframework.boot.autoconfigure.condition;
1818

19-
import java.util.HashMap;
20-
import java.util.Map;
19+
import java.util.Collections;
2120

2221
import org.junit.Test;
2322

@@ -49,7 +48,7 @@ public void expressionIsTrue() {
4948
}
5049

5150
@Test
52-
public void expressionEvaluatesToTrueRegisterBean() {
51+
public void expressionEvaluatesToTrueRegistersBean() {
5352
this.contextRunner.withUserConfiguration(MissingConfiguration.class)
5453
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
5554
}
@@ -75,10 +74,8 @@ public void expressionEvaluationWithNoBeanFactoryDoesNotMatch() {
7574

7675
private AnnotatedTypeMetadata mockMetaData(String value) {
7776
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
78-
Map<String, Object> attributes = new HashMap<>();
79-
attributes.put("value", value);
8077
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
81-
.willReturn(attributes);
78+
.willReturn(Collections.singletonMap("value", value));
8279
return metadata;
8380
}
8481

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void setMappings(PropertyMapping[] mappings) {
174174

175175
private static final class CacheKey {
176176

177-
private Object key;
177+
private final Object key;
178178

179179
private CacheKey(Object key) {
180180
this.key = key;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringProfileAction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ public void begin(InterpretationContext ic, String name, Attributes attributes)
6767
}
6868

6969
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
70+
if (this.environment == null) {
71+
return false;
72+
}
7073
String[] profileNames = StringUtils.trimArrayElements(StringUtils
7174
.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
72-
if (this.environment == null || profileNames.length == 0) {
75+
if (profileNames.length == 0) {
7376
return false;
7477
}
7578
for (int i = 0; i < profileNames.length; i++) {

0 commit comments

Comments
 (0)