Commit 58cf5284 by Dave Syer

Remove extra (redundant) condition

A problem in Spring Boot means that the extra conditions are combined with OR not AND, so it's a bug to have more than one until that gets fixed (in an AnyNestedCondition). See https://github.com/spring-projects/spring-boot/pull/6672
parent 4602fc11
...@@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
...@@ -204,7 +203,8 @@ public class EurekaClientAutoConfiguration { ...@@ -204,7 +203,8 @@ public class EurekaClientAutoConfiguration {
@Target({ ElementType.TYPE, ElementType.METHOD }) @Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Conditional(OnRefreshScopeCondition.class) @ConditionalOnClass(RefreshScope.class)
@ConditionalOnBean(RefreshAutoConfiguration.class)
@interface ConditionalOnRefreshScope { @interface ConditionalOnRefreshScope {
} }
...@@ -219,24 +219,10 @@ public class EurekaClientAutoConfiguration { ...@@ -219,24 +219,10 @@ public class EurekaClientAutoConfiguration {
static class MissingClass { static class MissingClass {
} }
@ConditionalOnClass(RefreshScope.class)
@ConditionalOnMissingBean(RefreshAutoConfiguration.class) @ConditionalOnMissingBean(RefreshAutoConfiguration.class)
static class MissingScope { static class MissingScope {
} }
} }
private static class OnRefreshScopeCondition extends AllNestedConditions {
public OnRefreshScopeCondition() {
super(ConfigurationPhase.REGISTER_BEAN);
}
@ConditionalOnClass(RefreshScope.class)
@ConditionalOnBean(RefreshAutoConfiguration.class)
static class FoundScope {
}
}
} }
...@@ -112,8 +112,8 @@ public class EurekaClientAutoConfigurationTests { ...@@ -112,8 +112,8 @@ public class EurekaClientAutoConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.context, "server.port=8989", EnvironmentTestUtils.addEnvironment(this.context, "server.port=8989",
"eureka.client.serviceUrl.defaultZone=http://user:foo@example.com:80/eureka"); "eureka.client.serviceUrl.defaultZone=http://user:foo@example.com:80/eureka");
setupContext(MockClientConfiguration.class); setupContext(MockClientConfiguration.class);
//ApacheHttpClient4 http = this.context.getBean(ApacheHttpClient4.class); // ApacheHttpClient4 http = this.context.getBean(ApacheHttpClient4.class);
//Mockito.verify(http).addFilter(Matchers.any(HTTPBasicAuthFilter.class)); // Mockito.verify(http).addFilter(Matchers.any(HTTPBasicAuthFilter.class));
} }
private void testNonSecurePort(String propName) { private void testNonSecurePort(String propName) {
......
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