diff --git a/client.go b/client.go index 8f07e426f..da3779b46 100644 --- a/client.go +++ b/client.go @@ -459,6 +459,14 @@ func (client *client) RefreshBrokers(addrs []string) error { delete(client.brokers, broker.ID()) } + for _, broker := range client.seedBrokers { + _ = broker.Close() + } + + for _, broker := range client.deadSeeds { + _ = broker.Close() + } + client.seedBrokers = nil client.deadSeeds = nil diff --git a/client_test.go b/client_test.go index 60020e5af..4fe4873d2 100644 --- a/client_test.go +++ b/client_test.go @@ -528,11 +528,11 @@ func TestClientRefreshBrokers(t *testing.T) { initialSeed.Returns(metadataResponse1) c, err := NewClient([]string{initialSeed.Addr()}, NewTestConfig()) - client := c.(*client) - if err != nil { t.Fatal(err) } + defer c.Close() + client := c.(*client) if len(client.Brokers()) != 2 { t.Error("Meta broker is not 2")