From 2cdcd4f6d1fcbe5599f0aa0fb90cd0a8c7b6d83e Mon Sep 17 00:00:00 2001 From: Andrew Baptist Date: Fri, 31 Mar 2023 08:51:57 -0400 Subject: [PATCH] rpc: correctly check for nil before cast As part of the fix of #99104, a cast without a nil check was introduced. This PR addresses that by only casting if it is known to be not nil. Epic: none Fixes: #100275 Release note: None --- pkg/rpc/context.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/context.go b/pkg/rpc/context.go index dc7c5dc4068f..5a6c39c5fca2 100644 --- a/pkg/rpc/context.go +++ b/pkg/rpc/context.go @@ -2715,13 +2715,14 @@ func (rpcCtx *Context) loadOrCreateConnAttempt( select { case <-previousAttempt.initialHeartbeatDone: // The connection attempt was completed, return the outcome of it. - err := previousAttempt.err.Load().(error) + err := previousAttempt.err.Load() if err == nil { // If it completed without error then don't track the connection // anymore. If it did have an error we need to track it until it later gets cleared. rpcCtx.dialbackMu.m[nodeID] = nil + return nil } - return err + return err.(error) default: // We still don't know the outcome of the previous attempt. For now // allow this attempt to continue and check in the future.