Skip to content

Commit

Permalink
bugfix nil pointer no target discovered
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Mar 2, 2021
1 parent 691e2f7 commit 476f5f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion internal/net/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,12 @@ func (g *gRPCClient) Connect(ctx context.Context, addr string, dopts ...DialOpti
g.atomicAddrs.Add(addr)
return conn, nil
}
log.Warnf("failed to reconnect unhealthy pool addr= %s\terror= %s", addr, err.Error())
log.Warnf("failed to reconnect unhealthy pool addr= %s\terror= %s\t trying to disconnect", addr, func() string {
if err != nil {
return err.Error()
}
return "connection response is nil or pool is nil"
}())
err = g.Disconnect(ctx, addr)
if err != nil {
log.Warnf("failed to disconnect unhealthy pool addr= %s\terror= %s", addr, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion internal/net/grpc/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func New(ctx context.Context, opts ...Option) (c Conn, err error) {
}

func (p *pool) Connect(ctx context.Context) (c Conn, err error) {
if p.closing.Load().(bool) {
if p.closing.Load().(bool) || p == nil{
return p, nil
}

Expand Down

0 comments on commit 476f5f9

Please sign in to comment.