From 9842341bd02c879dadfcd374b80c91cd1bf10b21 Mon Sep 17 00:00:00 2001 From: kwall Date: Fri, 1 Apr 2022 19:09:58 +0100 Subject: [PATCH] fix: prevent RefreshController leaking controller The RefreshController API leaked the broker that was previously in the controller role. --- client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 8f07e426f..29961470a 100644 --- a/client.go +++ b/client.go @@ -533,7 +533,10 @@ func (client *client) Controller() (*Broker, error) { func (client *client) deregisterController() { client.lock.Lock() defer client.lock.Unlock() - delete(client.brokers, client.controllerID) + if controller, ok := client.brokers[client.controllerID]; ok { + _ = controller.Close() + delete(client.brokers, client.controllerID) + } } // RefreshController retrieves the cluster controller from fresh metadata