diff --git a/src/Microsoft.Azure.EventHubs/Primitives/RetryExponential.cs b/src/Microsoft.Azure.EventHubs/Primitives/RetryExponential.cs index 49c0e59..5914df3 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/RetryExponential.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/RetryExponential.cs @@ -49,12 +49,6 @@ namespace Microsoft.Azure.EventHubs TimeSpan retryAfter = this.minimumBackoff.Add(TimeSpan.FromMilliseconds(nextRetryIntervalSeconds * 1000 + nextRetryIntervalMilliseconds)); retryAfter = retryAfter.Add(TimeSpan.FromSeconds(baseWaitTimeSecs)); - // Don't retry if remaining time isn't enough. - if (remainingTime.TotalSeconds < Math.Max(retryAfter.TotalSeconds, ClientConstants.TimerToleranceInSeconds)) - { - return null; - } - return retryAfter; } diff --git a/src/Microsoft.Azure.EventHubs/Primitives/RetryPolicy.cs b/src/Microsoft.Azure.EventHubs/Primitives/RetryPolicy.cs index c80f729..d4bba51 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/RetryPolicy.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/RetryPolicy.cs @@ -95,7 +95,16 @@ namespace Microsoft.Azure.EventHubs } } - return this.OnGetNextRetryInterval(clientId, lastException, remainingTime, baseWaitTime); + var retryAfter = this.OnGetNextRetryInterval(clientId, lastException, remainingTime, baseWaitTime); + + // Don't retry if remaining time isn't enough. + if (retryAfter == null || + remainingTime.TotalSeconds < Math.Max(retryAfter.Value.TotalSeconds, ClientConstants.TimerToleranceInSeconds)) + { + return null; + } + + return retryAfter; } } } \ No newline at end of file