Skip to content

Commit 105c5e2

Browse files
authored
#4236: make ignore check case-insensitive (#4256)
1 parent e13640d commit 105c5e2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

spring-boot-admin-docs/src/site/docs/server/01-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ __Discovery configuration options__
7373
| spring.boot.admin.discovery.enabled | Enables the DiscoveryClient-support for the admin server. | true |
7474
| spring.boot.admin.discovery.converter.management-context-path | Will be appended to the service-url of the discovered service when the management-url is converted by the DefaultServiceInstanceConverter. | /actuator |
7575
| spring.boot.admin.discovery.converter.health-endpoint-path | Will be appended to the management-url of the discovered service when the health-url is converted by the DefaultServiceInstanceConverter. | "health" |
76-
| spring.boot.admin.discovery.ignored-services | This services will be ignored when using discovery and not registered as application. Supports simple patterns (e.g. "foo*", "*bar", "foo*bar*"). | |
76+
| spring.boot.admin.discovery.ignored-services | This services will be ignored when using discovery and not registered as application. Supports simple patterns (e.g. "foo*", "*bar", "foo*bar*"). The check is case-insensitive. | |
7777
| spring.boot.admin.discovery.services | This services will be included when using discovery and registered as application. Supports simple patterns (e.g. "foo*", "*bar", "foo*bar*"). | "*" |
7878
| spring.boot.admin.discovery.ignored-instances-metadata | Instances of services will be ignored if they contain at least one metadata item that matches this list. (e.g. "discoverable=false") | |
7979
| spring.boot.admin.discovery.instances-metadata | Instances of services will be included if they contain at least one metadata item that matches this list. (e.g. "discoverable=true") | |

spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ protected boolean shouldRegisterService(final String serviceId) {
160160
}
161161

162162
protected boolean matchesPattern(String serviceId, Set<String> patterns) {
163-
return patterns.stream().anyMatch((pattern) -> PatternMatchUtils.simpleMatch(pattern, serviceId));
163+
return patterns.stream()
164+
.anyMatch((pattern) -> PatternMatchUtils.simpleMatch(pattern.toLowerCase(), serviceId.toLowerCase()));
164165
}
165166

166167
protected boolean shouldRegisterInstanceBasedOnMetadata(ServiceInstance instance) {

spring-boot-admin-server-cloud/src/test/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListenerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ public void should_not_register_instance_when_serviceId_is_ignored() {
9191
StepVerifier.create(this.registry.getInstances()).verifyComplete();
9292
}
9393

94+
@Test
95+
public void should_not_register_instance_when_serviceId_is_ignored_caseInsensitive() {
96+
when(this.discovery.getServices()).thenReturn(singletonList("service"));
97+
when(this.discovery.getInstances("service"))
98+
.thenReturn(singletonList(new DefaultServiceInstance("test-1", "service", "localhost", 80, false)));
99+
100+
this.listener.setIgnoredServices(singleton("SERVICE"));
101+
this.listener.onInstanceRegistered(new InstanceRegisteredEvent<>(new Object(), null));
102+
103+
StepVerifier.create(this.registry.getInstances()).verifyComplete();
104+
}
105+
94106
@Test
95107
public void should_not_register_instance_when_instanceMetadata_is_ignored() {
96108
when(this.discovery.getServices()).thenReturn(singletonList("service"));

0 commit comments

Comments
 (0)