Skip to content

Commit

Permalink
fix(internal/gensupport): don't prematurely close timers (#1856)
Browse files Browse the repository at this point in the history
quitAfterTimer should only be closed when function breaks or
returns as it is created outside of the for loop. Tested with
local replacing and fixes failing TestIndefiniteRetries test with
the patch.

Updates: googleapis/google-cloud-go#7410
  • Loading branch information
codyoss authored Feb 13, 2023
1 parent 3fb5b61 commit 8efd00d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/gensupport/resumable.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
}
return prepareReturn(resp, err)
case <-pauseTimer.C:
quitAfterTimer.Stop()
case <-quitAfterTimer.C:
pauseTimer.Stop()
return prepareReturn(resp, err)
Expand All @@ -231,7 +230,6 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
case <-quitAfterTimer.C:
return prepareReturn(resp, err)
default:
quitAfterTimer.Stop()
}

resp, err = rx.transferChunk(ctx)
Expand All @@ -243,6 +241,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err

// Check if we should retry the request.
if !errorFunc(status, err) {
quitAfterTimer.Stop()
break
}

Expand Down

0 comments on commit 8efd00d

Please sign in to comment.