Skip to content

Support multi-segment additional health endpoint paths - #51470

Merged
wilkinsona merged 1 commit into
spring-projects:mainfrom
Wanbinyu:gh-48374-multisegment-health-path
Sep 16, 2026
Merged

wilkinsona merged 1 commit into
spring-projects:mainfrom
Wanbinyu:gh-48374-multisegment-health-path

Conversation

@Wanbinyu

Copy link
Copy Markdown
Contributor

This allows a health group's additional-path to contain multiple path segments on either the main or management server.

AdditionalHealthEndpointPath now 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:test
  • MVC, WebFlux, and Jersey HealthEndpointAdditionalPathIntegrationTests
  • Checkstyle for each changed Java source set

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Aug 27, 2026
@Wanbinyu
Wanbinyu marked this pull request as ready for review August 27, 2026 06:40
@wilkinsona wilkinsona self-assigned this Sep 11, 2026
Comment on lines +395 to +397
if (patternTokens.length > 0 && !"**".equals(patternTokens[patternTokens.length - 1])) {
return pathTokens;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@wilkinsona wilkinsona added this to the 4.2.x milestone Sep 15, 2026
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. labels Sep 15, 2026
@wilkinsona
wilkinsona force-pushed the gh-48374-multisegment-health-path branch from bccae9c to 3aa96f2 Compare September 16, 2026 09:31
@wilkinsona wilkinsona modified the milestones: 4.2.x, 4.2.0-M2 Sep 16, 2026
@wilkinsona
wilkinsona merged commit 333d336 into spring-projects:main Sep 16, 2026
3 checks passed
@wilkinsona

Copy link
Copy Markdown
Member

Thank you, @Wanbinyu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multi-segment paths when mapping a health group to an additional path

3 participants