diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java index 9db53f4329..b576b440df 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java @@ -297,20 +297,12 @@ public final class EndpointRequest { } List antPath(String... parts) { - List matchers = new ArrayList<>(); - this.servletPaths.stream().map((p) -> { - if (StringUtils.hasText(p) && !p.equals("/")) { - return p; - } - return ""; - }).distinct().forEach((path) -> { - StringBuilder pattern = new StringBuilder(path); - for (String part : parts) { - pattern.append(part); - } - matchers.add(new AntPathRequestMatcher(pattern.toString())); - }); - return matchers; + return this.servletPaths.stream() + .map((p) -> (StringUtils.hasText(p) && !p.equals("/") ? p : "")) + .distinct() + .map((path) -> Arrays.stream(parts) + .collect(Collectors.joining("", path, ""))) + .map(AntPathRequestMatcher::new).collect(Collectors.toList()); } }