Fix querycoord panic when stop nil conn of querynoClient (#7346)

Signed-off-by: xige-16 <xi.ge@zilliz.com>
This commit is contained in:
xige-16 2021-08-28 12:51:57 +08:00 committed by GitHub
parent cc99bae250
commit af574d17d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -127,7 +127,11 @@ func (c *Client) Start() error {
}
func (c *Client) Stop() error {
return c.conn.Close()
c.cancel()
if c.conn != nil {
c.conn.Close()
}
return nil
}
// Register dummy

View File

@ -0,0 +1,15 @@
package grpcquerynodeclient
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNilClient(t *testing.T) {
client, err := NewClient(context.Background(), "test")
assert.Nil(t, err)
err = client.Stop()
assert.Nil(t, err)
}