Improve Randomness in JitteredDelay Class #3315
Closed
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
This pull request replaces the usage of System.Random with System.Security.Cryptography.RandomNumberGenerator in the JitteredDelay class. This enhances the randomness and security of random number generation. We generate a random long value, normalize it to a double in the range [0, 1), and use this double value to add a random amount of jitter to the retry delay.
Motivation and Context
The change is required to enhance the security and randomness of the JitteredDelay class, particularly for security-sensitive operations. It improves the overall robustness of the system's retry mechanism.
Testing
The changes have been tested to ensure the JitteredDelay class still functions as expected, and the new randomness generation does not introduce any errors or unexpected behavior. Tests were run in a local development environment.
Types of changes
Checklist
License