ServletEndpoints do not consider server.servlet.path #13124
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I have changed ServletEndpointManagementContextConfiguration and documentation to support ServletEndpoints to have same path than web management endpoints.
The problem
If your server has no management port set and there is a "server.servlet.path" set, the ServletEndpoint registration path would not consider "server.servlet.path" as all other web management endpoints. So the resulting path for servlet endpoints will look different from other web management paths.
In this case, for example, with jolokia:
How the jolokia endpoint is currently:
http://host:port/context-path/actuator/jolokia
Examples of other endpoints that I am trying to mimic:
http://host:port/context-path/servlet-path/actuator/health
http://host:port/context-path/servlet-path/actuator/auditevents
http://host:port/context-path/servlet-path/actuator/beans
How the jolokia endpoint should be:
http://host:port/context-path/servlet-path/actuator/jolokia
The fix
This pull requests ensures the desired behaviour, and add to the documentation the information that it does consider "server.servlet.path" whenever management port is not set.
The way it was implemented is that ServletEndpointManagementContextConfiguration will have two configurations, one for different context (different management port), and another for same context.
The configuration for different context will be the same as before.
The configuration for same context will pull "server.servlet.path" from environment and add it to the servlet registration base path.