-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Spring Framework 5.3 introduced the PathPattern
as an efficient alternative to AntPathMatcher
URL matching.
Spring Boot 2.4 introduced (in issue #21694) a new config property to enable the PathPattern
-based URL matching; spring.mvc.pathmatch.matching-strategy=path_pattern_parser
.
This works well for URL matching of @Controller
s etc, but org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping
does not respect the aforementioned config property - it always uses the AntPathMatcher
-based URL matching. I.e. all actuator endpoints still have their URLs matched with AntPathMatcher
. This is a bit painful since the WebMvcEndpointHandlerMapping
typically has higher priority than the RequestMappingHandlerMapping
and hence is asked to try to match every incoming request before the RequestMappingHandlerMapping
gets to do its thing. I.e. every request is still matched with the AntPathMatcher
even if we use spring.mvc.pathmatch.matching-strategy=path_pattern_parser
.
I would expect the WebMvcEndpointHandlerMapping
to respect the configuration and use the PathPattern
-based URL matching in this case so that I can completely eliminate the use of AntPathMatcher
.
The root cause of this seems to be that WebMvcEndpointHandlerMapping
initialises its AbstractWebMvcEndpointHandlerMapping#builderConfig
via a private static method that does not take any configuration into account.
In contrast RequestMappingHandlerMapping
(that respects the configuration property) initialises
RequestMappingHandlerMapping#config
in #afterPropertiesSet()
with the pattern parser typically injected via org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#configurePathMatch
.