-
Notifications
You must be signed in to change notification settings - Fork 163
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
ExponentialBackoff strategy recreates Random instance each time #944
Comments
On .NET Framework it is incorrect to recreate Random instances each time, these should instead be one per instance. On .NET Core and later this is not a limitation, but the libraries share a codebase. Fixes box#944
I also noticed that Unfortunately adding a new parameter to the |
I don't think we would make a breakthrough change for such a small change at this point. But if it were possible to extend |
@mwwoda I put together a non-breaking way to share the |
Nice! Maybe, you could create a PR based on this, so we can discuss it here? |
* fix: do not recreate Random each time On .NET Framework it is incorrect to recreate Random instances each time, these should instead be one per instance. On .NET Core and later this is not a limitation, but the libraries share a codebase. Fixes #944 * Use a thread safe Random instance #944 * Forgot to commit csproj change #944 * Address PR comment #944
Description of the Issue
Within the ExponentialBackoff retry strategy, the
Random
instance is recreated each timeGetRetryTimeout
is called. This is an anti-pattern, and incorrect for .NET Framework based projects:https://learn.microsoft.com/en-us/dotnet/api/system.random.-ctor
Note: this does not apply to Box.V2.Core, but they share the same repository.
Steps to Reproduce
ExponentialBackoff.GetRetryTimeout
calls in a row on .NET Framework 4.6.2+ targetsExpected Behavior
A single
Random
instance is used in accordance with .NET Framework best practices.Error Message, Including Stack Trace
N/A
Screenshots
N/A
Versions Used
.Net SDK: Box.V2 5.7.0
Windows: N/A
The text was updated successfully, but these errors were encountered: