Fix credential reloading by default + gracefully handle missing files #6632
+138
−17
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.




Fix credential reloading by default + gracefully handle missing files
Motivation and Context
Modifications
This PR addresses two, related issues by:
ProfileFileSupplier.reloadWhenModifiedmethod - this ensures that credential provider chains that rely on this method will fallback to the next available provider AND that if the file is eventually created, it can be used.ProfileFileSupplier.defaultSupplierwhich uses refreshable suppliers which correctly cache ProfileFiles (mitigating the performance impact seen in some earlier versions) while also allowing updates by checking the file modification time.Q: What about the performance impact?
There were a few previous PRs (#4850 and #3950) that made changes to default profile file suppliers to mitigate performance impacts. However, the performance degredation (loading profileFile on every request) comes from using
ProfileFile::defaultProfileFileas a supplier and not from using theProfileFileSupplier.defaultSupplier. Using ``ProfileFile::defaultProfileFilehas NO caching and no refresh logic - every singleget` call will always re-load the file(s). The `ProfileFileSupplier.defaultSupplier` uses file modification times to ensure that the file(s) are reloaded only when changed.Benchmark Results
#3950 identified performance issues when running
JsonProtocolBenchmark, so we use the same here (since this would load a default client and make many requests):Testing
New and existing unit tests.
Ran reproduction test cases from both #4268 and #6615.
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