Skip to content

Commit

Permalink
Move random instance to class level
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Aug 18, 2021
1 parent 8bf0c04 commit 0e0eeea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Auth0.ManagementApi/HttpClientManagementConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class HttpClientManagementConnection : IManagementConnection, IDisposable

readonly HttpClient httpClient;
readonly HttpClientManagementConnectionOptions options;
readonly Random random = new Random();
bool ownHttpClient;

/// <summary>
Expand Down Expand Up @@ -219,7 +220,7 @@ private async Task<TResult> Retry<TResult>(Func<Task<TResult>> retryable)
var MIN_REQUEST_RETRY_DELAY = 100;

var wait = Convert.ToInt32(BASE_DELAY * Math.Pow(2, nrOfTries - 1));
wait = new Random().Next(wait + 1, wait + MAX_REQUEST_RETRY_JITTER);
wait = random.Next(wait + 1, wait + MAX_REQUEST_RETRY_JITTER);
wait = Math.Min(wait, MAX_REQUEST_RETRY_DELAY);
wait = Math.Max(wait, MIN_REQUEST_RETRY_DELAY);

Expand Down

0 comments on commit 0e0eeea

Please sign in to comment.