Skip to content

Commit ea16c4d

Browse files
authored
disable Atlas binding when using SBN3 (#589)
The property name the SBN check uses changed in SBN3. Update it to check for both variants.
1 parent edd1577 commit ea16c4d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

iep-spring-atlas/src/main/java/com/netflix/iep/atlas/NoSbnCondition.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
class NoSbnCondition implements Condition {
2727
@Override
2828
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
29-
String v = context.getEnvironment().getProperty("management.metrics.export.atlas.enabled");
30-
return v == null;
29+
String sbn2 = context.getEnvironment().getProperty("management.metrics.export.atlas.enabled");
30+
String sbn3 = context.getEnvironment().getProperty("management.atlas.metrics.export.enabled");
31+
return sbn2 == null && sbn3 == null;
3132
}
3233
}

iep-spring-atlas/src/test/java/com/netflix/iep/atlas/AtlasConfigurationTest.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void registryIsBound() {
4343
}
4444

4545
@Test(expected = NoSuchBeanDefinitionException.class)
46-
public void registryIsNotBoundIfSbnIsPresent() {
46+
public void registryIsNotBoundIfSbn2IsPresent() {
4747
Map<String, Object> props = new HashMap<>();
4848
props.put("management.metrics.export.atlas.enabled", "true");
4949
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
@@ -56,4 +56,19 @@ public void registryIsNotBoundIfSbnIsPresent() {
5656
context.getBean(Registry.class);
5757
}
5858
}
59+
60+
@Test(expected = NoSuchBeanDefinitionException.class)
61+
public void registryIsNotBoundIfSbn3IsPresent() {
62+
Map<String, Object> props = new HashMap<>();
63+
props.put("management.atlas.metrics.export.enabled", "true");
64+
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
65+
context.getEnvironment()
66+
.getPropertySources()
67+
.addFirst(new MapPropertySource("test", props));
68+
context.register(AtlasConfiguration.class);
69+
context.refresh();
70+
context.start();
71+
context.getBean(Registry.class);
72+
}
73+
}
5974
}

0 commit comments

Comments
 (0)