Merge pull request #13616 from izeye:polish-20180630
* pr/13616: Polish
This commit is contained in:
commit
00883a4eac
|
|
@ -81,11 +81,12 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getUrlMappings(String endpointPath, String name) {
|
private String[] getUrlMappings(String endpointPath, String name) {
|
||||||
return this.basePaths.stream()
|
return this.basePaths
|
||||||
.map((bp) -> (bp != null ? bp + "/" + endpointPath : "/" + endpointPath))
|
.stream().map((basePath) -> (basePath != null
|
||||||
.distinct().map((p) -> {
|
? basePath + "/" + endpointPath : "/" + endpointPath))
|
||||||
logger.info("Registered '" + p + "' to " + name);
|
.distinct().map((path) -> {
|
||||||
return (p.endsWith("/") ? p + "*" : p + "/*");
|
logger.info("Registered '" + path + "' to " + name);
|
||||||
|
return (path.endsWith("/") ? path + "*" : path + "/*");
|
||||||
}).toArray(String[]::new);
|
}).toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,9 @@ class OnExpressionCondition extends SpringBootCondition {
|
||||||
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
|
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
|
||||||
.get("value");
|
.get("value");
|
||||||
expression = wrapIfNecessary(expression);
|
expression = wrapIfNecessary(expression);
|
||||||
String rawExpression = expression;
|
|
||||||
expression = context.getEnvironment().resolvePlaceholders(expression);
|
|
||||||
ConditionMessage.Builder messageBuilder = ConditionMessage
|
ConditionMessage.Builder messageBuilder = ConditionMessage
|
||||||
.forCondition(ConditionalOnExpression.class, "(" + rawExpression + ")");
|
.forCondition(ConditionalOnExpression.class, "(" + expression + ")");
|
||||||
|
expression = context.getEnvironment().resolvePlaceholders(expression);
|
||||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||||
if (beanFactory != null) {
|
if (beanFactory != null) {
|
||||||
boolean result = evaluateExpression(beanFactory, expression);
|
boolean result = evaluateExpression(beanFactory, expression);
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.condition;
|
package org.springframework.boot.autoconfigure.condition;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
@ -49,7 +48,7 @@ public class ConditionalOnExpressionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void expressionEvaluatesToTrueRegisterBean() {
|
public void expressionEvaluatesToTrueRegistersBean() {
|
||||||
this.contextRunner.withUserConfiguration(MissingConfiguration.class)
|
this.contextRunner.withUserConfiguration(MissingConfiguration.class)
|
||||||
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
||||||
}
|
}
|
||||||
|
|
@ -75,10 +74,8 @@ public class ConditionalOnExpressionTests {
|
||||||
|
|
||||||
private AnnotatedTypeMetadata mockMetaData(String value) {
|
private AnnotatedTypeMetadata mockMetaData(String value) {
|
||||||
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
|
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
|
||||||
Map<String, Object> attributes = new HashMap<>();
|
|
||||||
attributes.put("value", value);
|
|
||||||
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
|
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
|
||||||
.willReturn(attributes);
|
.willReturn(Collections.singletonMap("value", value));
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
||||||
|
|
||||||
private static final class CacheKey {
|
private static final class CacheKey {
|
||||||
|
|
||||||
private Object key;
|
private final Object key;
|
||||||
|
|
||||||
private CacheKey(Object key) {
|
private CacheKey(Object key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,12 @@ class SpringProfileAction extends Action implements InPlayListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
|
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
|
||||||
|
if (this.environment == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String[] profileNames = StringUtils.trimArrayElements(StringUtils
|
String[] profileNames = StringUtils.trimArrayElements(StringUtils
|
||||||
.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
|
.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
|
||||||
if (this.environment == null || profileNames.length == 0) {
|
if (profileNames.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < profileNames.length; i++) {
|
for (int i = 0; i < profileNames.length; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue