Skip to content

Migrate CompositeHealth/HealthComponent to Spring Boot 4 descriptor types#1038

Merged
steve-aom-elliott merged 1 commit into
mainfrom
sb4-composite-health-descriptor
Jun 15, 2026
Merged

Migrate CompositeHealth/HealthComponent to Spring Boot 4 descriptor types#1038
steve-aom-elliott merged 1 commit into
mainfrom
sb4-composite-health-descriptor

Conversation

@steve-aom-elliott

@steve-aom-elliott steve-aom-elliott commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What's missing

In Spring Boot 4 the actuator health response API was reorganised:

Spring Boot 3 Spring Boot 4
org.springframework.boot.actuate.health.HealthComponent (abstract) org.springframework.boot.health.actuate.endpoint.HealthDescriptor (abstract)
org.springframework.boot.actuate.health.CompositeHealth org.springframework.boot.health.actuate.endpoint.CompositeHealthDescriptor
HealthEndpoint.health() returns HealthComponent HealthEndpoint.health() returns HealthDescriptor

MigrateToModularStarters already handles every other org.springframework.boot.actuate.health.* type explicitly and then falls through to a catch-all ChangePackage that maps the remainder to org.springframework.boot.health.contributor. That catch-all sent CompositeHealth and HealthComponent to the wrong package and didn't rename the classes, so callers like the one below still failed to compile under SB4:

HealthComponent health = healthEndpoint.health();
if (health instanceof CompositeHealth composite) {
    body.put("components", composite.getComponents());
}

Change

Add two ChangeType entries before the catch-all ChangePackage, alongside the other types that move to health.actuate.endpoint:

  • org.springframework.boot.actuate.health.CompositeHealthorg.springframework.boot.health.actuate.endpoint.CompositeHealthDescriptor
  • org.springframework.boot.actuate.health.HealthComponentorg.springframework.boot.health.actuate.endpoint.HealthDescriptor

getComponents() exists on CompositeHealthDescriptor with the same signature shape (returning Map<String, HealthDescriptor>), so the rest of the call site doesn't need touching.

org.springframework.boot.actuate.health.Health is unchanged — it still ends up at org.springframework.boot.health.contributor.Health via the catch-all (it's the indicator output type, not a HealthDescriptor).

Test plan

  • New test MigrateActuateHealthPackage#migrateCompositeHealthAndHealthComponentToDescriptors exercises the instanceof + getComponents() pattern from a real controller
  • All tests in MigrateToModularStartersTest pass locally

…riptor types

In Spring Boot 4 the actuator health response API was reorganised: the
abstract `HealthComponent` was renamed to `HealthDescriptor` and its
composite subtype `CompositeHealth` was renamed to `CompositeHealthDescriptor`,
with both moving to `org.springframework.boot.health.actuate.endpoint`.

The existing catch-all `ChangePackage` from `actuate.health` to
`health.contributor` sent these to the wrong package and left the class
names unchanged, leaving callers that do `instanceof CompositeHealth` or
hold a `HealthComponent` returned by `HealthEndpoint.health()` failing to
compile.

Add explicit `ChangeType` entries before the catch-all, alongside the
other `health.actuate.endpoint` renames.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 15, 2026
@steve-aom-elliott steve-aom-elliott moved this from In Progress to Ready to Review in OpenRewrite Jun 15, 2026
@steve-aom-elliott steve-aom-elliott merged commit 51c0c9f into main Jun 15, 2026
1 check passed
@steve-aom-elliott steve-aom-elliott deleted the sb4-composite-health-descriptor branch June 15, 2026 15:20
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

boot-4.0 bug Something isn't working test provided

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant