diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java index 9c1d21a749..585fe7a219 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * Member predicate that matches based on {@code include} and {@code exclude} sets. @@ -54,12 +55,12 @@ class IncludeExcludeGroupMemberPredicate implements Predicate { if (names == null) { return Collections.emptySet(); } - Set cleaned = new LinkedHashSet<>(names); + Set cleaned = names.stream().map(this::clean).collect(Collectors.toCollection(LinkedHashSet::new)); return Collections.unmodifiableSet(cleaned); } private String clean(String name) { - return name.trim().toLowerCase(); + return name.trim(); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java index 3650dd65af..7944ac6251 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java @@ -68,6 +68,24 @@ class IncludeExcludeGroupMemberPredicateTests { assertThat(predicate).rejects("a", "b", "c", "d"); } + @Test + void testWhenCamelCaseIncludeAcceptsOnlyIncluded() { + Predicate predicate = include("myEndpoint").exclude(); + assertThat(predicate).accepts("myEndpoint").rejects("d"); + } + + @Test + void testWhenHyphenCaseIncludeAcceptsOnlyIncluded() { + Predicate predicate = include("my-endpoint").exclude(); + assertThat(predicate).accepts("my-endpoint").rejects("d"); + } + + @Test + void testWhenExtraWhitespaceAcceptsTrimmedVersion() { + Predicate predicate = include(" myEndpoint ").exclude(); + assertThat(predicate).accepts("myEndpoint").rejects("d"); + } + private Builder include(String... include) { return new Builder(include); }