Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR disables MSAL4J’s internal retry behavior for identity flows that use ConfidentialClientApplication, PublicClientApplication, and ManagedIdentityApplication, aiming to rely on Azure SDK retry policies instead (per issue #47765).
Changes:
- Call
disableInternalRetries()on MSAL application builders for confidential, public, and managed identity flows. - Add unit tests validating observed HTTP request count matches Azure-core retry settings (i.e., no extra MSAL retries).
- Document the change in
azure-identity’s changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientBase.java | Disables MSAL internal retries for confidential/public/managed identity MSAL builders. |
| sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/IdentityClientTests.java | Adds tests that assert total HTTP requests equals configured retry attempts + initial call. |
| sdk/identity/azure-identity/CHANGELOG.md | Adds a Bugs Fixed entry describing MSAL internal retry disablement. |
| StepVerifier.create(client.authenticateWithUsernamePassword(request, "test-username", "test-password")) | ||
| .expectErrorMatches(e -> e instanceof ClientAuthenticationException).verify(); | ||
|
|
||
| assertEquals(RETRY_COUNT + 1, requestCount.get(), "With maxRetries=" + RETRY_COUNT + ", total requests should be " + (RETRY_COUNT + 1) + " (1 initial + " + RETRY_COUNT + " retries)"); |
| .identityClientOptions(options) | ||
| .build(); | ||
|
|
||
| StepVerifier.create(client.authenticateWithManagedIdentityMsalClient(new TokenRequestContext().addScopes("https://management.azure.com/.default"))) |
Comment on lines
239
to
+242
| applicationBuilder = applicationBuilder.logPii(options.isUnsafeSupportLoggingEnabled()) | ||
| .authority(authorityUrl) | ||
| .instanceDiscovery(options.isInstanceDiscoveryEnabled()); | ||
| .instanceDiscovery(options.isInstanceDiscoveryEnabled()) | ||
| .disableInternalRetries(); |
Comment on lines
311
to
+314
| builder = builder.logPii(options.isUnsafeSupportLoggingEnabled()) | ||
| .authority(authorityUrl) | ||
| .instanceDiscovery(options.isInstanceDiscoveryEnabled()); | ||
| .instanceDiscovery(options.isInstanceDiscoveryEnabled()) | ||
| .disableInternalRetries(); |
Comment on lines
+413
to
+415
| ManagedIdentityApplication.Builder miBuilder = ManagedIdentityApplication.builder(managedIdentityId) | ||
| .logPii(options.isUnsafeSupportLoggingEnabled()) | ||
| .disableInternalRetries(); |
|
|
||
| ### Bugs Fixed | ||
|
|
||
| - Disabled MSAL's internal retry for Confidential Client, Managed Identity and Public Client Applications. |
| StepVerifier.create(client.authenticateWithConfidentialClient(request)) | ||
| .expectErrorMatches(e -> e instanceof MsalServiceException).verify(); | ||
|
|
||
| assertEquals(RETRY_COUNT + 1, requestCount.get(), "With maxRetries=" + RETRY_COUNT + ", total requests should be " + (RETRY_COUNT + 1) + " (1 initial + " + RETRY_COUNT + " retries)"); |
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.
Description
Disable MSAL's internal retries and use its own for ConfientialClient (.e.g ClientSecretCredential), Public Client and Managed Identity.
Fixes #47765
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines