Skip to content

Commit

Permalink
disable Atlas binding when using SBN3 (#589)
Browse files Browse the repository at this point in the history
The property name the SBN check uses changed in SBN3. Update
it to check for both variants.
  • Loading branch information
brharrington authored Sep 26, 2023
1 parent edd1577 commit ea16c4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
class NoSbnCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
String v = context.getEnvironment().getProperty("management.metrics.export.atlas.enabled");
return v == null;
String sbn2 = context.getEnvironment().getProperty("management.metrics.export.atlas.enabled");
String sbn3 = context.getEnvironment().getProperty("management.atlas.metrics.export.enabled");
return sbn2 == null && sbn3 == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void registryIsBound() {
}

@Test(expected = NoSuchBeanDefinitionException.class)
public void registryIsNotBoundIfSbnIsPresent() {
public void registryIsNotBoundIfSbn2IsPresent() {
Map<String, Object> props = new HashMap<>();
props.put("management.metrics.export.atlas.enabled", "true");
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
Expand All @@ -56,4 +56,19 @@ public void registryIsNotBoundIfSbnIsPresent() {
context.getBean(Registry.class);
}
}

@Test(expected = NoSuchBeanDefinitionException.class)
public void registryIsNotBoundIfSbn3IsPresent() {
Map<String, Object> props = new HashMap<>();
props.put("management.atlas.metrics.export.enabled", "true");
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.getEnvironment()
.getPropertySources()
.addFirst(new MapPropertySource("test", props));
context.register(AtlasConfiguration.class);
context.refresh();
context.start();
context.getBean(Registry.class);
}
}
}

0 comments on commit ea16c4d

Please sign in to comment.