diff --git a/exponential.go b/exponential.go index 3d34532..2c56c1e 100644 --- a/exponential.go +++ b/exponential.go @@ -147,6 +147,9 @@ func (b *ExponentialBackOff) incrementCurrentInterval() { // Returns a random value from the following interval: // [currentInterval - randomizationFactor * currentInterval, currentInterval + randomizationFactor * currentInterval]. func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration { + if randomizationFactor == 0 { + return currentInterval // make sure no randomness is used when randomizationFactor is 0. + } var delta = randomizationFactor * float64(currentInterval) var minInterval = float64(currentInterval) - delta var maxInterval = float64(currentInterval) + delta