Merge branch '2.0.x'

pull/13619/merge
Stephane Nicoll 6 years ago
commit 0b48e223f3

@ -81,11 +81,12 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
}
private String[] getUrlMappings(String endpointPath, String name) {
return this.basePaths.stream()
.map((bp) -> (bp != null ? bp + "/" + endpointPath : "/" + endpointPath))
.distinct().map((p) -> {
logger.info("Registered '" + p + "' to " + name);
return (p.endsWith("/") ? p + "*" : p + "/*");
return this.basePaths
.stream().map((basePath) -> (basePath != null
? basePath + "/" + endpointPath : "/" + endpointPath))
.distinct().map((path) -> {
logger.info("Registered '" + path + "' to " + name);
return (path.endsWith("/") ? path + "*" : path + "/*");
}).toArray(String[]::new);
}

@ -42,10 +42,9 @@ class OnExpressionCondition extends SpringBootCondition {
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
.get("value");
expression = wrapIfNecessary(expression);
String rawExpression = expression;
expression = context.getEnvironment().resolvePlaceholders(expression);
ConditionMessage.Builder messageBuilder = ConditionMessage
.forCondition(ConditionalOnExpression.class, "(" + rawExpression + ")");
.forCondition(ConditionalOnExpression.class, "(" + expression + ")");
expression = context.getEnvironment().resolvePlaceholders(expression);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
if (beanFactory != null) {
boolean result = evaluateExpression(beanFactory, expression);

@ -16,8 +16,7 @@
package org.springframework.boot.autoconfigure.condition;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import org.junit.Test;
@ -49,7 +48,7 @@ public class ConditionalOnExpressionTests {
}
@Test
public void expressionEvaluatesToTrueRegisterBean() {
public void expressionEvaluatesToTrueRegistersBean() {
this.contextRunner.withUserConfiguration(MissingConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
}
@ -75,10 +74,8 @@ public class ConditionalOnExpressionTests {
private AnnotatedTypeMetadata mockMetaData(String value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
Map<String, Object> attributes = new HashMap<>();
attributes.put("value", value);
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
.willReturn(attributes);
.willReturn(Collections.singletonMap("value", value));
return metadata;
}

@ -174,7 +174,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
private static final class CacheKey {
private Object key;
private final Object key;
private CacheKey(Object key) {
this.key = key;

@ -68,9 +68,12 @@ class SpringProfileAction extends Action implements InPlayListener {
}
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
if (this.environment == null) {
return false;
}
String[] profileNames = StringUtils.trimArrayElements(StringUtils
.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
if (this.environment == null || profileNames.length == 0) {
if (profileNames.length == 0) {
return false;
}
for (int i = 0; i < profileNames.length; i++) {

Loading…
Cancel
Save