From dafd47467758aab323439bead39a299eac1866ba Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Sat, 23 May 2020 13:35:17 -0700 Subject: [PATCH] clientv3: cancel the client if there is no endpoint Signed-off-by: Ted Yu --- clientv3/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clientv3/client.go b/clientv3/client.go index 2fab7af78..ed4a98677 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -460,7 +460,8 @@ func newClient(cfg *Config) (*Client, error) { client.resolverGroup.SetEndpoints(cfg.Endpoints) if len(cfg.Endpoints) < 1 { - return nil, fmt.Errorf("at least one Endpoint must is required in client config") + client.cancel() + return nil, fmt.Errorf("at least one Endpoint is required in client config") } dialEndpoint := cfg.Endpoints[0]