Fix GraalVM native image compatibility for AzureIdentityEnvVars#47940
Fix GraalVM native image compatibility for AzureIdentityEnvVars#47940g2vinay merged 1 commit intoAzure:mainfrom
Conversation
ed780cf to
84b313f
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses a GraalVM native-image compatibility issue in azure-identity by removing a reflection-dependent reference to AzureIdentityEnvVars when reading the AZURE_TOKEN_CREDENTIALS configuration value, preventing a NullPointerException in native builds.
Changes:
- Removed
AzureIdentityEnvVarsusage fromIdentityClientOptions.loadFromConfigurationand replaced it with the"AZURE_TOKEN_CREDENTIALS"string key. - Added a changelog entry documenting the GraalVM native-image
NullPointerExceptionfix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java | Avoids referencing AzureIdentityEnvVars during configuration loading to prevent GraalVM native-image reflection/static-init issues. |
| sdk/identity/azure-identity/CHANGELOG.md | Documents the GraalVM native-image NullPointerException fix in the unreleased section. |
...ty/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java
Outdated
Show resolved
Hide resolved
Replace reflection-dependent AzureIdentityEnvVars enum usage with direct string literal to avoid NullPointerException in GraalVM native images. The ExpandableStringEnum base class uses reflection for static field initialization, which doesn't work in native images without explicit configuration. Using the string literal 'AZURE_TOKEN_CREDENTIALS' directly eliminates the reflection dependency while maintaining identical runtime behavior. Fixes NullPointerException in IdentityClientOptions.loadFromConfiguration when running in GraalVM native builds (e.g., Quarkus applications).
84b313f to
36c8024
Compare
|
I've a basic question- As per my understanding, when we reference the static fields in AzureIdentityEnvVars, it calls the If a user running a native image tries to execute DAC-> |
Resolves #47106
Replace reflection-dependent AzureIdentityEnvVars enum usage with direct string literal to avoid NullPointerException in GraalVM native images.
The ExpandableStringEnum base class uses reflection for static field initialization, which doesn't work in native images without explicit configuration. Using the string literal 'AZURE_TOKEN_CREDENTIALS' directly eliminates the reflection dependency while maintaining identical runtime behavior.
Fixes NullPointerException in IdentityClientOptions.loadFromConfiguration when running in GraalVM native builds (e.g., Quarkus applications).