fix: improve check for validity of token#76
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #76 +/- ##
============================================
+ Coverage 28.51% 28.65% +0.13%
- Complexity 721 723 +2
============================================
Files 145 145
Lines 5277 5283 +6
Branches 567 567
============================================
+ Hits 1505 1514 +9
+ Misses 3714 3712 -2
+ Partials 58 57 -1 ☔ View full report in Codecov by Sentry. |
4676fa4 to
a0ce129
Compare
a0ce129 to
c34968c
Compare
rhamzeh
reviewed
Apr 26, 2024
rhamzeh
reviewed
Apr 26, 2024
rhamzeh
reviewed
Apr 26, 2024
rhamzeh
reviewed
Apr 26, 2024
rhamzeh
reviewed
Apr 26, 2024
4 tasks
rhamzeh
approved these changes
Apr 26, 2024
This was referenced Apr 30, 2024
Merged
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
I've removed the jitter here as I'm not sure what it added and it made testing harder as we didn't have predictability. If we want to guard against a potential "thundering herd" on the token refresh then I think we'd be better off attempting to only allow one call to the token endpoints to occur at a time (not sure how to do this in Java myself, maybe if we used synchronized onexchangeToken?The jitter calculation has been changed to use
nextInt(TOKEN_EXPIRY_BUFFER_THRESHOLD_IN_SEC), this will return a value up to our 300 seconds limit that we can use to prevent multiple calls at the same time. From my testingnextLongcould potentially return negative values so I believe this is not safe to use, given we want our jitter to be up to 300 seconds more then wenextIntwith the bound is safer.References
Resolves #75
Review Checklist
main