File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,15 @@ func (r *Retry) Next() bool {
172
172
return false
173
173
}
174
174
175
+ // Check for cancellation first to prioritize over timer.
176
+ select {
177
+ case <- r .opts .Closer :
178
+ return false
179
+ case <- r .ctx .Done ():
180
+ return false
181
+ default :
182
+ }
183
+
175
184
backoff , actualWait , shouldAttempt := r .calcDurationScopedBackoff ()
176
185
177
186
if ! shouldAttempt && r .opts .PreemptivelyCancel {
@@ -192,15 +201,6 @@ func (r *Retry) Next() bool {
192
201
r .backingOffHook (actualWait )
193
202
}
194
203
195
- // Check for cancellation first to prioritize over timer.
196
- select {
197
- case <- r .opts .Closer :
198
- return false
199
- case <- r .ctx .Done ():
200
- return false
201
- default :
202
- }
203
-
204
204
select {
205
205
case <- r .opts .Closer :
206
206
return false
Original file line number Diff line number Diff line change @@ -469,7 +469,7 @@ func TestRetryWithMaxDuration(t *testing.T) {
469
469
preRetryFunc : func () {
470
470
cancelCtxFunc ()
471
471
},
472
- expectedTimeSpent : time . Millisecond ,
472
+ expectedTimeSpent : 0 ,
473
473
expectedErr : true ,
474
474
},
475
475
{
@@ -486,7 +486,7 @@ func TestRetryWithMaxDuration(t *testing.T) {
486
486
preRetryFunc : func () {
487
487
close (closeCh )
488
488
},
489
- expectedTimeSpent : time . Millisecond ,
489
+ expectedTimeSpent : 0 ,
490
490
expectedErr : true ,
491
491
},
492
492
}
You can’t perform that action at this time.
0 commit comments