Repository navigation
Support multi-segment additional health endpoint paths - #51470
Conversation
| if (patternTokens.length > 0 && !"**".equals(patternTokens[patternTokens.length - 1])) { | ||
| return pathTokens; | ||
| } |
There was a problem hiding this comment.
I'd prefer that the handler mapping did not have this knowledge of the path patterns.
While reviewing the previous iteration, I was concerned that it would miss something. That led to me opening spring-projects/spring-framework#37270. If that's implemented in Framework, it would allow us to use an implementation that's similar to what we already do on the WebFlux side.
In the meantime, I think we'd be better using getPatternParser to get hold of the parser and passing it into ServletWebOperationAdapter. It can then re-parse the path pattern string that's available in the BEST_MATCHING_PATTERN_ATTRIBUTE. org.springframework.web.util.ServletRequestPathUtils.getParsedRequestPath(ServletRequest) can be used to access the parsed request path.
There was a problem hiding this comment.
Thanks, Andy. Updated in bccae9c to pass getPatternParser() into ServletWebOperationAdapter, re-parse BEST_MATCHING_PATTERN_ATTRIBUTE, and use ServletRequestPathUtils.getParsedRequestPath(request).pathWithinApplication() with extractPathWithinPattern. This removes the manual pattern-token checks and follows the WebFlux approach.
Local verification passed: all 321 spring-boot-webmvc tests, 62 Actuator documentation tests, and 53 MvcWebEndpointIntegrationTests, including the existing multi-segment additional health path, health component, and path-decoding coverage. Checkstyle and formatting checks also passed. The new CI run is in progress.
Signed-off-by: Wan bin yu <[email protected]> See spring-projectsgh-51470
bccae9c to
3aa96f2
Compare
|
Thank you, @Wanbinyu. |
This allows a health group's
additional-pathto contain multiple path segments on either the main or management server.AdditionalHealthEndpointPathnow accepts multi-segment values, and health endpoint routing resolves the group using the longest matching additional-path prefix. Spring MVC's exact-path handling now forwards the complete path consistently with WebFlux and Jersey. The shared integration test fixture verifies the behavior across all three web stacks, and the reference documentation has been updated.Closes #48374
Tests:
./gradlew :module:spring-boot-health:testHealthEndpointAdditionalPathIntegrationTests