Skip to content

Commit 6c45d6b

Browse files
committed
fix #14
1 parent 9831e1e commit 6c45d6b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

exponential.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ const (
7474

7575
// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
7676
func NewExponentialBackOff() *ExponentialBackOff {
77-
return &ExponentialBackOff{
77+
b := &ExponentialBackOff{
7878
InitialInterval: DefaultInitialInterval,
7979
RandomizationFactor: DefaultRandomizationFactor,
8080
Multiplier: DefaultMultiplier,
8181
MaxInterval: DefaultMaxInterval,
8282
MaxElapsedTime: DefaultMaxElapsedTime,
8383
Clock: SystemClock,
8484
}
85+
b.Reset()
86+
return b
8587
}
8688

8789
type systemClock struct{}

exponential_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ func TestGetElapsedTime(t *testing.T) {
7777
func TestMaxElapsedTime(t *testing.T) {
7878
var exp = NewExponentialBackOff()
7979
exp.Clock = &TestClock{start: time.Time{}.Add(10000 * time.Second)}
80-
if exp.NextBackOff() != Stop {
81-
t.Error("error2")
82-
}
8380
// Change the currentElapsedTime to be 0 ensuring that the elapsed time will be greater
8481
// than the max elapsed time.
8582
exp.startTime = time.Time{}

0 commit comments

Comments
 (0)