Repository navigation
Conversation
ApplyUserAgentStage runs on the calling thread in the async pipeline and joined the selected auth scheme's identity future to read the credential provider name for the User-Agent business metric. Async clients therefore blocked their caller until credentials resolved, even though signing already waits on the identity future asynchronously. The stage now takes the client type. For async clients it reads the provider name only when the identity future has already completed normally, and otherwise leaves the credential provider metric out of the User-Agent. Sync clients still wait for the identity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the hand-rolled executor and Future.get timeout with JUnit's assertTimeoutPreemptively, which runs the call on its own thread and fails the test if it does not return in time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The async path only needs to avoid waiting on an identity that is still being resolved. An identity future that has already completed exceptionally can be joined without blocking, so join it as before and let the failure surface from this stage, rather than skipping the metric and deferring the failure to signing inside the retry loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The regression test needs a timeout because its identity future never completes, so reintroducing the blocking join would hang the test indefinitely rather than fail it.
1 open issue
What changed in this PR
This PR addresses the User-Agent blocking issue in #7560 within the SDK’s core HTTP pipeline. Async clients omit the credential provider metric while identity resolution is pending, while sync clients retain their existing waiting behavior.
Changes:
- Pass the client type into
ApplyUserAgentStageand avoid waiting for unresolved async identities. - Add stage-level tests and an async pipeline regression test.
- Add a release note describing the fix.
| File | Description |
|---|---|
core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/pipeline/stages/ApplyUserAgentStageTest.java |
Tests resolved, pending, and failed identities and sync waiting behavior. |
core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/AsyncHttpClientIdentityResolutionTest.java |
Checks that async execution returns while identity resolution is pending. |
core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/ApplyUserAgentStage.java |
Skips pending identity metrics for async clients. |
core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/AmazonSyncHttpClient.java |
Supplies the sync client type to the stage. |
core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/AmazonAsyncHttpClient.java |
Supplies the async client type to the stage. |
.changes/next-release/bugfix-AWSSDKforJavav2-7084844.json |
Documents the nonblocking User-Agent change. |
Review effort: Balanced
The identity future in this test never completes, so a regression back to a blocking join would hang the build instead of failing the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.

ApplyUserAgentStagenow checks the client type and will omit the provider name if the client type is async and the identity has yet to be resolved. Once it has been resolved (assuming it is cached) then it includes it in future requests. Every built-inAwsCredentialsProviderorSdkTokenProviderblocks the calling thread (they really shouldn't but that is a separate issue) and so it will be resolved and this change has no effect.The alternative solution would be to move this stage to a different part of the pipeline so that it could run after identity resolution is guaranteed to have finished but that is a larger change.
Motivation and Context
Fixes #7560
Modifications
ClientTypeparameter to theApplyUserAgentStageconstructor.ASYNCorSYNCdepending on whether it is called fromAmazonAsyncHttpClientorAmazonSyncHttpClient.ApplyUserAgentStage, changegetBusinessMetricsStringandcredentialProviderBusinessMetricsto be instance methods so that they can access theclientTypefield.resolvedIdentitywhich checks theclientTypeand whether theidentityfuture has completed:ASYNCand it has not completed then it returns noIdentity.ASYNCand it has completed normally then it returns the resolvedIdentity.ASYNCand it has completed exceptionally then it throws.SYNCand it blocks as it did previously.Testing
Ran:
./mvnw install -pl :sdk-core./mvnw clean installServerNotRespondingTestis flakey.ServerConnectivityErrorMessageTestfails every time and seems to be environmental.Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.AI tools
License