@@ -225,7 +225,7 @@ type baseClient struct {
225225 maintNotificationsManager * maintnotifications.Manager
226226 maintNotificationsManagerLock sync.RWMutex
227227
228- credListeners map [uint64 ]auth.CredentialsListener
228+ credListeners map [* pool. Conn ]auth.CredentialsListener
229229 credListenersLock sync.RWMutex
230230}
231231
@@ -305,7 +305,7 @@ func (c *baseClient) _getConn(ctx context.Context) (*pool.Conn, error) {
305305// The credentials listener is removed from the map when the connection is closed.
306306func (c * baseClient ) connReAuthCredentialsListener (poolCn * pool.Conn ) (auth.CredentialsListener , func ()) {
307307 c .credListenersLock .RLock ()
308- credListener , ok := c .credListeners [poolCn . GetID () ]
308+ credListener , ok := c .credListeners [poolCn ]
309309 c .credListenersLock .RUnlock ()
310310 if ok {
311311 return credListener .(auth.CredentialsListener ), func () {
@@ -319,7 +319,7 @@ func (c *baseClient) connReAuthCredentialsListener(poolCn *pool.Conn) (auth.Cred
319319 c .reAuthConnection (),
320320 c .onAuthenticationErr (),
321321 )
322- c .credListeners [poolCn . GetID () ] = newCredListener
322+ c .credListeners [poolCn ] = newCredListener
323323 return newCredListener , func () {
324324 c .removeCredListener (poolCn )
325325 }
@@ -328,7 +328,7 @@ func (c *baseClient) connReAuthCredentialsListener(poolCn *pool.Conn) (auth.Cred
328328func (c * baseClient ) removeCredListener (poolCn * pool.Conn ) {
329329 c .credListenersLock .Lock ()
330330 defer c .credListenersLock .Unlock ()
331- delete (c .credListeners , poolCn . GetID () )
331+ delete (c .credListeners , poolCn )
332332}
333333
334334func (c * baseClient ) reAuthConnection () func (poolCn * pool.Conn , credentials auth.Credentials ) error {
@@ -990,6 +990,10 @@ func NewClient(opt *Options) *Client {
990990 panic (fmt .Errorf ("redis: failed to create pubsub pool: %w" , err ))
991991 }
992992
993+ if c .opt .StreamingCredentialsProvider != nil {
994+ c .credListeners = make (map [* pool.Conn ]auth.CredentialsListener )
995+ }
996+
993997 // Initialize maintnotifications first if enabled and protocol is RESP3
994998 if opt .MaintNotificationsConfig != nil && opt .MaintNotificationsConfig .Mode != maintnotifications .ModeDisabled && opt .Protocol == 3 {
995999 err := c .enableMaintNotificationsUpgrades ()
0 commit comments