Skip to content

Commit

Permalink
bugfix: RefreshBrokers leaks original seed brokers
Browse files Browse the repository at this point in the history
  • Loading branch information
k-wall committed Apr 1, 2022
1 parent 9473433 commit f41a8d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ func (client *client) RefreshBrokers(addrs []string) error {
delete(client.brokers, broker.ID())
}

for _, broker := range client.seedBrokers {
_ = broker.Close()
}

client.seedBrokers = nil
client.deadSeeds = nil

Expand Down
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f41a8d4

Please sign in to comment.