From 0e0eeeac89e0f0f5d50fff9e01d4b2348b821764 Mon Sep 17 00:00:00 2001 From: Frederik Date: Wed, 18 Aug 2021 12:41:41 +0200 Subject: [PATCH] Move random instance to class level --- src/Auth0.ManagementApi/HttpClientManagementConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Auth0.ManagementApi/HttpClientManagementConnection.cs b/src/Auth0.ManagementApi/HttpClientManagementConnection.cs index 81f1095ec..3d1c1dbaf 100644 --- a/src/Auth0.ManagementApi/HttpClientManagementConnection.cs +++ b/src/Auth0.ManagementApi/HttpClientManagementConnection.cs @@ -20,6 +20,7 @@ public class HttpClientManagementConnection : IManagementConnection, IDisposable readonly HttpClient httpClient; readonly HttpClientManagementConnectionOptions options; + readonly Random random = new Random(); bool ownHttpClient; /// @@ -219,7 +220,7 @@ private async Task Retry(Func> 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);