Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one health group can be exposed using management.endpoint.health.group.xxx.additional-path=server:/newpath when using Jersey #36250

Closed
kent-rosenkoetter-at-nordstrom opened this issue Jul 5, 2023 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@kent-rosenkoetter-at-nordstrom

@Override
protected Resource createResource(EndpointMapping endpointMapping, WebOperation operation) {
WebOperationRequestPredicate requestPredicate = operation.getRequestPredicate();
String matchAllRemainingPathSegmentsVariable = requestPredicate.getMatchAllRemainingPathSegmentsVariable();
if (matchAllRemainingPathSegmentsVariable != null) {
for (HealthEndpointGroup group : this.groups) {
AdditionalHealthEndpointPath additionalPath = group.getAdditionalPath();
if (additionalPath != null) {
return getResource(endpointMapping, operation, requestPredicate, additionalPath.getValue(),
this.serverNamespace, (data, pathSegmentsVariable) -> data.getUriInfo().getPath());
}
}
}
return null;
}

When using Spring Boot with both Jersey and Actuator, the health endpoint only allows one health group to have an additional-path configured. All other additional paths are ignored except for the first that appears in the configuration file.

management.endpoint.health.group.liveness.additional-path=server:/health1
management.endpoint.health.group.readiness.additional-path=server:/ready1

Only /health1 will be available as a JAX-RS Resource. The available health endpoints will be:

  • /actuator/health/liveness
  • /actuator/health/readiness
  • /health1
@kent-rosenkoetter-at-nordstrom kent-rosenkoetter-at-nordstrom changed the title Only one health group can be exposed using management.endpoint.health.group.xxx.additional-path: server:/newpath when using Jersey. Only one health group can be exposed using management.endpoint.health.group.xxx.additional-path=server:/newpath when using Jersey. Jul 5, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 5, 2023
@kent-rosenkoetter-at-nordstrom
Copy link
Author

I suspect the fix will be to override the JerseyEndpointResourceFactory.createEndpointResources method instead of only overriding createResource.

It would be much easier to write the fix if this code were written using a normal loop instead of the streams API:

endpoints.stream()
.flatMap((endpoint) -> endpoint.getOperations().stream())
.map((operation) -> createResource(endpointMapping, operation))
.forEach(resources::add);

Then it would be trivial to add more than one Resource per endpoint.

@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 6, 2023
@philwebb philwebb added this to the 2.7.x milestone Jul 6, 2023
@wilkinsona wilkinsona self-assigned this Jul 6, 2023
@wilkinsona wilkinsona modified the milestones: 2.7.x, 2.7.14 Jul 7, 2023
@wilkinsona wilkinsona changed the title Only one health group can be exposed using management.endpoint.health.group.xxx.additional-path=server:/newpath when using Jersey. Only one health group can be exposed using management.endpoint.health.group.xxx.additional-path=server:/newpath when using Jersey Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants