Skip to content

Commit a3312a4

Browse files
committed
Made random locally scoped to GetNextWaitInterval method
1 parent 5fef750 commit a3312a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/SendGrid/Reliability/RetryDelegatingHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class RetryDelegatingHandler : DelegatingHandler
2323

2424
private readonly ReliabilitySettings settings;
2525

26-
private readonly Random random = new Random();
27-
2826
/// <summary>
2927
/// Initializes a new instance of the <see cref="RetryDelegatingHandler"/> class.
3028
/// </summary>
@@ -107,8 +105,10 @@ private static void ThrowHttpRequestExceptionIfResponseCodeCanBeRetried(HttpResp
107105

108106
private TimeSpan GetNextWaitInterval(int numberOfAttempts)
109107
{
108+
var random = new Random();
109+
110110
var delta = (int)((Math.Pow(2.0, numberOfAttempts) - 1.0) *
111-
this.random.Next(
111+
random.Next(
112112
(int)(this.settings.DeltaBackOff.TotalMilliseconds * 0.8),
113113
(int)(this.settings.DeltaBackOff.TotalMilliseconds * 1.2)));
114114

0 commit comments

Comments
 (0)