From 5231902faccf1d6b18846d18c33acd1511874bd5 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Thu, 3 Jun 2021 10:28:47 -0600 Subject: [PATCH] patch on prior commit: test os.SyscallError first --- pkg/kgo/errors.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/kgo/errors.go b/pkg/kgo/errors.go index f18ca45d..e884a402 100644 --- a/pkg/kgo/errors.go +++ b/pkg/kgo/errors.go @@ -36,14 +36,18 @@ func isRetriableBrokerErr(err error) bool { // appears as a hard failure can actually be retried. For example, a // failed dial can be retried, maybe the resolver temporarily had a // problem. - var tempErr interface{ Temporary() bool } - if errors.As(err, &tempErr) { - return tempErr.Temporary() - } + // + // We favor testing os.SyscallError first, because net.OpError _always_ + // implements Temporary, so if we test that first, it'll return false + // in many cases when we want to return true from os.SyscallError. var se *os.SyscallError if errors.As(err, &se) { return true } + var tempErr interface{ Temporary() bool } + if errors.As(err, &tempErr) { + return tempErr.Temporary() + } switch err { case errChosenBrokerDead, errCorrelationIDMismatch: