Skip to content

fix: AutoConfigureAfter covers Spring Boot 3.5.x metrics package#41

Open
endrju19 wants to merge 2 commits intomainfrom
micrometer
Open

fix: AutoConfigureAfter covers Spring Boot 3.5.x metrics package#41
endrju19 wants to merge 2 commits intomainfrom
micrometer

Conversation

@endrju19
Copy link
Copy Markdown
Collaborator

@endrju19 endrju19 commented May 8, 2026

Summary

  • OkapiMicrometerAutoConfiguration declared @AutoConfigureAfter(name = ...) against the Spring Boot 4.0 package only. On 3.5.x — listed in the README compatibility matrix — that class does not exist, the hint is silently dropped, and the auto-configuration can be evaluated before MeterRegistry is registered, skipping the whole listener/metrics/refresher trio.
  • Lists both class locations (3.5.x and 4.0.x) so the hint is honored on every supported runtime; Spring Boot tolerates missing entries per name, so listing both is safe.
  • Adds a reflection-based test that fails the build whenever no declared @AutoConfigureAfter target resolves on the runtime classpath. The existing functional test passed because it pre-registered MeterRegistry via withBean, bypassing ordering — the new test exercises the actual contract.

Test plan

  • ./gradlew :okapi-spring-boot:test — Spring Boot 4.0.6 (default)
  • ./gradlew :okapi-spring-boot:test -PspringBootVersion=3.5.12 -PspringVersion=6.2.17 — Spring Boot 3.5.12
  • ./gradlew :okapi-spring-boot:ktlintCheck
  • Verified that the new test fails on 3.5.12 before the fix and passes after

Closes #36

endrju19 added 2 commits May 8, 2026 16:13
…ring Boot 3.5.x and 4.0.x

The @AutoConfigureAfter hint referenced only the Spring Boot 4.0 package
layout. On 3.5.x the class is in a different package, the name-based hint
was silently dropped, and OkapiMicrometerAutoConfiguration could be
evaluated before MeterRegistry was registered — skipping the entire
auto-configuration.

List both class locations so the hint is honored on every supported
Spring Boot version listed in the README compatibility matrix.

Adds a reflection-based test that fails the build whenever none of the
declared @AutoConfigureAfter targets resolve on the runtime classpath,
which would have caught this bug on the existing 3.5.12 CI matrix entry.

Closes #36
- Tighten Class.forName guard to ClassNotFoundException only. The previous
  runCatching swallowed every Throwable, which would have masked
  NoClassDefFoundError or LinkageError under mixed-jar classpath conditions
  and let the very regression the test guards against slip through silently.

- Rename the existing wiring test to "...when a MeterRegistry bean is provided
  directly". Its setup pre-registers MeterRegistry via withBean, sidestepping
  auto-config ordering — it's a useful DI-wiring test but never exercised the
  ordering contract. The new name advertises that limitation.

- Add a higher-fidelity functional ordering test that loads Spring Boot's real
  MetricsAutoConfiguration / CompositeMeterRegistryAutoConfiguration /
  SimpleMetricsExportAutoConfiguration via withConfiguration (no
  pre-registered MeterRegistry). MeterRegistry is now created by Spring Boot,
  so @AutoConfigureAfter on OkapiMicrometerAutoConfiguration must actually
  resolve and order correctly for the listener to be wired. Verified to FAIL
  on Spring Boot 3.5.12 when the production fix is reverted, then PASS once
  reapplied.

The Spring Boot auto-config FQCNs are resolved through a small
resolveSpringBootClass helper that tries the 3.5.x and 4.0.x package layouts
in order, so a single test exercises both supported runtimes from the CI
matrix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OkapiMicrometerAutoConfiguration silently skipped on Spring Boot 3.5.x due to wrong @AutoConfigureAfter target

1 participant