fix(native): register DefaultMetaProvider reflection hint to unbreak nativeTest - #172
Open
adityamparikh wants to merge 3 commits into
Open
fix(native): register DefaultMetaProvider reflection hint to unbreak nativeTest#172adityamparikh wants to merge 3 commits into
adityamparikh wants to merge 3 commits into
Conversation
Spring AI 1.1.6 introduced a MetaUtils.getMeta() call path in the sync resource providers that reflectively invokes the no-arg constructor on org.springaicommunity.mcp.context.DefaultMetaProvider. AOT does not generate this hint, so every @SpringBootTest fails in nativeTest with: IllegalArgumentException: Required no-arg constructor not found in org.springaicommunity.mcp.context.DefaultMetaProvider ... Caused by: NoSuchMethodException: org.springaicommunity.mcp.context.DefaultMetaProvider.<init>() during ApplicationContext refresh, and the remaining tests cascade-fail on "ApplicationContext failure threshold (1) exceeded". Register the constructor hint in SolrNativeHints alongside the existing SolrJ and MCP response-record hints. registerTypeIfPresent keeps it a no-op if a future Spring AI release removes or relocates the class. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
The test reflects into SolrJ's private basicAuthAuthorizationStr field to verify basic-auth wiring. That field is not registered for reflection under GraalVM's closed-world model, so ReflectionUtils.findField returns null and the assertion fails in nativeTest (it passes on the JVM). The basic-auth wiring logic itself is fully covered by the JVM test run, so disable the reflection-based assertions in native image, matching the repo convention for tests that don't survive the closed-world assumption. This failure is currently masked in CI: every @SpringBootTest fails first on the DefaultMetaProvider reflection gap fixed in the previous commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
…icates Review follow-up on this PR. The hints were previously exercised only by nativeTest -Pnative (a full GraalVM build), so an accidentally removed registration would surface as a hard-to-diagnose native-only startup failure. SolrNativeHintsTest pins the DefaultMetaProvider constructor hint, a representative SolrJ type, an MCP response record, and the logback.xml resource pattern on the plain JVM path, where a regression fails in seconds. Also moves the SolrConfigAuthTest disable rationale above the annotation so spotless stops mangling the comment wrap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
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
./gradlew nativeTest -Pnativefails on every branch and PR (e.g. PR #159's run: 68 test failures). All failures collapse to a single root cause duringApplicationContextrefresh:The context fails to load 8 times and the remaining ~60 tests cascade-fail on
ApplicationContext failure threshold (1) exceeded.Root cause
Spring AI 1.1.6 introduced a
MetaUtils.getMeta()call path in the sync resource providers that reflectively invokes the no-arg constructor ofDefaultMetaProviderwhen building theresourceSpecsbean. Spring AOT does not generate a reflection hint for it, so the constructor is invisible in GraalVM's closed world. BecauseresourceSpecsis part of the real application context (not just tests), the native server binary is affected too — currently masked in CI because the docker integration tests fail earlier on an image-tag mismatch (companion PR: #173).Changes
fix(native): registerMemberCategory.INVOKE_DECLARED_CONSTRUCTORSfororg.springaicommunity.mcp.context.DefaultMetaProviderinSolrNativeHints, alongside the existing SolrJ and MCP response-record hints.registerTypeIfPresentkeeps it a no-op if a future Spring AI release removes or relocates the class.test(config):@DisabledInNativeImageonSolrConfigAuthTest. It reflects into SolrJ's privatebasicAuthAuthorizationStrfield, which is not registered for reflection in the closed world, so its 5 tests fail in nativeTest (they pass on the JVM, which fully covers the basic-auth wiring). This second gap is currently masked by theDefaultMetaProviderfailure — fixing only that one would leave nativeTest red with these 5.Verification (local, GraalVM CE 25 / macOS arm64)
nativeTest -Pnativereproduces CI's failure (every@SpringBootTestfails onDefaultMetaProvider; with only the hint fix applied, 5SolrConfigAuthTestfailures remain).nativeTest -Pnative→ 213 tests successful, 0 failed (136 skipped: the Mockito/@DisabledInNativeImageset)../gradlew spotlessCheck buildpasses (JVM path unaffected).bootBuildImage -Pnative+dockerIntegrationTest -Pnative→ the native stdio image passes the MCP protocol suite (39 tests) and smoke tests. The http leg as well:dockerIntegrationTest -Pnative -Pprofile=http→DockerImageHttpIntegrationTest(6 tests) passes againstsolr-mcp:1.0.0-SNAPSHOT-native-http.Merge order
This PR and #173 are independent to review but jointly required for a green
native.yml: this one fixes thenativeTestjob; the companion fixes the image tag the docker jobs resolve. Suggest merging this one first (its docker jobs will still be red on the pre-existing tag mismatch), then the companion turns the matrix fully green.🤖 Generated with Claude Code