← Back to Pull requests

[Spring] Fix native Key Vault binding and Binder/JMS initialization #51271

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 16, 2026 09:17 UTC
Author

1. Summary

Fixes Azure/azure-sdk-for-java#51209.

Fix native Key Vault property-source binding, retain global properties in
AOT-generated contexts, and complete the Service Bus JMS initialization paths
exercised by the Queue sample. This PR remains a draft.

Thanks to @arnabnandy7 for Azure/azure-sdk-for-java#51238. The imported contribution
retains its original Author, AuthorDate, and Signed-off-by.

2. Changes

2.1. Key Vault and shared properties

  • Consolidate the existing registrars into

  • implementation.SpringCloudAzureAutoconfigureRuntimeHints.
  • Register binding hints for global Azure and Key Vault property-source settings.

  • Environment post-processors bind these directly, outside configuration-bean
    registration.
  • Preserve the JSON streaming methods on SecretItem and SecretBundle.

  • Register the AzureIdentityEnvVars constructor independently of Key Vault:

  • other services also initialize Azure Identity when the Secrets SDK is absent.
  • Replace the global-properties instance supplier with a declarative

  • PropertiesFactory.buildProperties bean definition and remove the old AOT
    exclusion filter.
  • Preserve runtime Environment binding, name-based overrides, definition defaults

  • and parent/child isolation. Add generated-context tests for both Service Bus
    and Event Hubs Binders; their added spring-core-test dependencies are test-only.

    2.2. Other manual-binding paths

    Register these additional binding roots:

    | Properties | Why explicit hints are needed |
    | --- | --- |
    | AzureJdbcPasswordlessProperties | A JDBC bean post-processor binds it directly; it is not a configuration-properties bean. |
    | AzureCosmosProperties, AzureEventHubsProperties, AzureServiceBusProperties, AzureStorageBlobProperties, AzureStorageQueueProperties | Their ConnectionDetails factories use Binder without @ConfigurationProperties. Automatic hints from the alternative ordinary factory do not cover this branch. |

    new/Bindable.ofInstance does not preserve the reflective property accessors.
    Registrations are conditional on optional SDK classes; this is not blanket
    registration of every properties class.

    2.3. Service Bus JMS follow-up

  • Replace all three opaque JMS instance suppliers (plain, caching and pooling)

  • with analyzable factory-method bean definitions.
  • Preserve bean names, the existing selection/fallback table, runtime properties,

  • user-provided instance factories, ordered customizers, cache/pool settings and
    the pool's stop destruction method.
  • Keep optional cache/pool method signatures in separate internal factories.

  • Retain Qpid public methods needed for URI prefetch options and the exact

  • factory / extensionMap fields used by the Standard-tier AMQP customizer.
  • Retain Qpid's custom FactoryFinder descriptors and matching factory metadata

  • for amqps, failover, SSL transport, PLAIN/ANONYMOUS SASL and default noop
    tracing. These descriptors are not ordinary Java ServiceLoader files.
  • Register the ordered Connection/Session proxy interface combinations that

  • Spring caching creates from concrete JMS capabilities.
  • Use string-based TypeReference values for optional JMS interfaces rather

  • than production imports/class literals. Register only when the relevant
    dependencies are present.

    No public API or runtime dependency versions are changed. User-facing fixes are
    recorded in the central Spring changelog.

    3. Failure reference

    These are separate failures encountered as native initialization progressed:

    | Path | Observed error / symptom |
    | --- | --- |
    | Key Vault binding | Skip configuring Key Vault PropertySource because spring.cloud.azure.keyvault.secret.property-sources is empty. |
    | Azure Identity | ExceptionInInitializerError caused by NPE in IdentityClientOptions.loadFromConfiguration (tested Identity 1.18.4). |
    | Secret deserialization | InvalidDefinitionException: Cannot construct instance of ...SecretItem in a native image. |
    | Binder child context | No qualifying bean of type ...AzureGlobalProperties required by credential auto-configuration. |
    | JMS AOT | Error processing bean with name 'jmsConnectionFactory': instance supplier is not supported (also pooling). |
    | Qpid URI binding | Unused parameters=[{prefetchPolicy.all=0}]. This connection factory cannot be started. |
    | Standard-tier customization | Field factory can't found on class ...ServiceBusJmsConnectionFactory; the following extensionMap access needs metadata too. |
    | Qpid provider discovery | Provider scheme NOT recognized: [failover], caused by missing META-INF/services/org/apache/qpid/jms/provider/failover. |
    | Cached JMS sending | MissingReflectionRegistrationError for a proxy implementing jakarta.jms.Connection. |

    The JDBC path also reproduced a missing AzureJdbcPasswordlessProperties
    constructor; the five ConnectionDetails paths reproduced missing property
    accessors. Their binding hints cover constructors, accessors and nested types.

    4. Validation

    2026-11-20 main synchronization: merged e3d46ee89df351b0f2ff40a1c954262101d5ad3d without rewriting PR history. The only conflict was the central Spring changelog; both sets of entries are retained, and this PR's implementation is unchanged. The merged reactor passes 214 focused Java tests (213 passed, 1 existing skip), Checkstyle and scoped SpotBugs. The full native build was not rerun for this synchronization; native results below describe the earlier validated artifacts.

    4.1. Automated and isolated checks

  • Latest focused autoconfigure suite: 124 tests, 0 failures, 0 errors, 0 skipped.

  • Includes 42 registrar tests and real AOT generation, compilation and execution
    for all three JMS factory branches.
  • Tests preserve runtime rather than build-time values, a custom factory

  • subclass, ordered customizers, cache/pool settings and actual pool shutdown.
  • New regressions failed for the expected missing hints or unsupported supplier

  • before the corresponding fixes. Existing factory/auto-configuration tests pass.
  • Checkstyle: 0 violations. Explicitly enabled scoped SpotBugs: 0 bugs, 0 errors.

  • No rules were relaxed.
  • Compile the production registrar with Java 17 after physically removing the

  • optional JMS JARs; loading it on the reduced classpath succeeds too.
  • Eight metadata exports are byte-identical before/after the string-based

  • optional-interface refactor, including no-JMS classpaths and Key Vault /
    passwordless filter combinations.
  • Earlier verification includes both Binders' generated child contexts, seven

  • real JMS factory/fallback classpaths, and 28 optional-service metadata scenarios.
  • The six-path JDBC/ConnectionDetails native fixture passes 31 assertions in two

  • runs with application-supplied candidate hints disabled.

    4.2. Real native samples

  • Service Bus JMS Queue: Windows, GraalVM 25.0.2, Boot 4.1.1 and locally built

  • SCA 7.5.0-beta.1; tested with azure-servicebus-jms 2.1.0 / Qpid 2.9.0.
    Two independent native processes each waited at least ten seconds after startup,
    returned HTTP 200 for a unique POST, and logged receipt of that exact message.
    The application processes were stopped afterward. Private connection settings
    and raw logs are not included in this PR.
  • Sample-side prerequisite, not part of this SDK PR: the Queue sample's

  • application-owned User ObjectMessage payload needs
    hints.serialization().registerType(User.class). This was added only in the
    separate local samples worktree, without changing its converter or trust rules.
    The SDK must not hard-code application payload classes.
  • The sample native compiler ran out of heap at 4 GB; a 6 GB heap with two threads

  • succeeded. This sample POM adjustment is also outside this SDK PR.
  • The real JMS runs preceded the final string-only proxy-hint refactor; the

  • metadata-equivalence checks above verify that refactor without claiming another
    full native rebuild.
  • Earlier Service Bus Binder native: generated child initializer creates the

  • correct Binder and reports binderCreated=true (Boot 4.1.2).
  • Earlier Key Vault native: the non-production fixture resolves correctly,

  • with a vault property source present and the secret matching the vault, without
    application-provided Azure hints.

    Focused checks do not replace the full-repository suite or a Linux native run.
    Whole-module coverage thresholds and documentation generation were skipped for
    the targeted local builds.

    5. Known limits and separate issues

  • Published signed SDK artifacts are a separate compatibility gate. Released

  • SDK classes and unsigned AOT classes generated in the same package can trigger:

      SecurityException: signer information does not match signer information
      of other classes in the same package
      

    This was reproduced with SCA 7.4.0. Passing native tests with local unsigned
    development artifacts does not prove that signed releases work. This PR does
    not remove signatures or disable verification.

  • RevApi exits successfully but reports internal nested-class scanning errors;

  • it is not treated as an unqualified complete API compatibility guarantee.
  • Event Hubs' full binding graph includes Blob checkpoint-store properties.

  • Without the Blob SDK its full hint registration is skipped to avoid resolving
    unavailable types; Event Hubs-only native binding without Blob is not verified.
  • The JMS real-service validation covers the Standard-tier Queue/SAS/TLS path

  • described above, not every authentication, WebSocket, tracing or JMS feature.
    Application payload serialization metadata remains the application's concern.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: arnabnandy7 Review duration: 9279m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #51271"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%