From a53adc717f861e844562a78daa356f21d2ccd700 Mon Sep 17 00:00:00 2001 From: O2 Date: Tue, 15 Aug 2023 02:53:49 +0800 Subject: [PATCH] fix bug : should drain channel of timer after stop (#612) --- interceptors/retry/retry.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interceptors/retry/retry.go b/interceptors/retry/retry.go index 42ed6bf07..2abdb43b6 100644 --- a/interceptors/retry/retry.go +++ b/interceptors/retry/retry.go @@ -260,7 +260,9 @@ func waitRetryBackoff(attempt uint, parentCtx context.Context, callOpts *options timer := time.NewTimer(waitTime) select { case <-parentCtx.Done(): - timer.Stop() + if !timer.Stop() { + <-timer.C + } return contextErrToGrpcErr(parentCtx.Err()) case <-timer.C: }