fix: AutoConfigureAfter covers Spring Boot 3.5.x metrics package#41
Open
fix: AutoConfigureAfter covers Spring Boot 3.5.x metrics package#41
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
OkapiMicrometerAutoConfigurationdeclared@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 beforeMeterRegistryis registered, skipping the whole listener/metrics/refresher trio.@AutoConfigureAftertarget resolves on the runtime classpath. The existing functional test passed because it pre-registeredMeterRegistryviawithBean, 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:ktlintCheckCloses #36