-
Notifications
You must be signed in to change notification settings - Fork 970
[IMDS] Token cache for Async client #3649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| waitingFutures.add(result); | ||
| } else { | ||
| CompletableFuture<Token> tokenRequest = startRefresh(result); | ||
| CompletableFutureUtils.forwardExceptionTo(result, tokenRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want this. A cancellation of the result future probably shouldn't fail the refresh that's happening in the background, because other (unrelated) calls might be waiting on that refresh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I think it's fine to remove it because we will still cancel the request made with the token after, it's only the token refresh call that would be not be cancellable by the users.
core/imds/src/main/java/software/amazon/awssdk/imds/internal/AsyncTokenCache.java
Show resolved
Hide resolved
core/imds/src/main/java/software/amazon/awssdk/imds/internal/AsyncTokenCache.java
Outdated
Show resolved
Hide resolved
core/imds/src/main/java/software/amazon/awssdk/imds/internal/AsyncTokenCache.java
Outdated
Show resolved
Hide resolved
- remove future error forwarding to cached request - replace future forward test by checking that no http requests were made - moved fragile tests to their owned class to prevent potential different results on different runs - added Test constants
|
SonarCloud Quality Gate failed.
|
Minor fixes to address feedback and update changelog file








Motivation and Context
Required as part of the async IMDS Client. The async client also needs to cache the token and reuse it if it is not expired on subsequent requests.
Modifications
Added AsyncTokenCache class, caching the token and returning a CompletableFuture.
Removed TokenCacheStrategy.
Moved some async HTTP request logic to an helper class.
Added log + javadoc.
Testing
Update async unit test to make them slightly more robust.
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.License