Skip to content

Introduce @ConditonalOnExposedEndpoint to avoid auto-configuring endpoints that cannot be accessed #16093

@bclozel

Description

@bclozel

Since #16090, the spring.jmx.enabled property has been set to false by default.

With that change, we should re-evaluate default enablement of Actuator endpoints since:

  • by default only "info" and "health" are exposed over HTTP
  • it doesn't make sense to consume resources to create those endpoints if they're not exposed in any way (JMX nor HTTP)

We could in this case avoid creating endpoints when possible; we should refine OnEnabledEndpointCondition and decide to enable a given endpoint with the following conditions (for example, with the "env" endpoint):

  1. Enable/disable the endpoint if explicitly configured with "management.endpoint.env.enabled"
  2. Enable/disable all endpoints if explicitly configured with "management.endpoints.enabled-by-default"
  3. Enable the endpoint if it is enabled by default with @Endpoint(id = "env", enableByDefault = true) and it is exposed as an HTTP endpoint (see "management.endpoints.web.exposure.include") or JMX is enabled and this endpoint is exposed over JMX (see "spring.jmx.enabled" and "management.endpoints.jmx.exposure.include")
  4. Otherwise, disable this endpoint

With this improvement, we don't need to change the defaults on @Endpoint annotations, as we still want to retain the difference between enablement and exposure; fr example, the "shutdown" endpoint is not enabled by default.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions