Repository navigation
Clear post-authentication hooks properly with pool.destroy - #4749
Merged
Merged
Conversation
atakavci
marked this pull request as ready for review
September 25, 2026 12:26
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 72d03e9. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
ConnectionPoolregisters a post-authentication hook on itsAuthXManagerbut never managed to remove it, becausethis::postAuthenticationyields a new object on every evaluation and the list removal never matched. Stale hooks on closed pools then threw fromevict()into the token manager's renewal cycle. On top of that,ConnectionPool.close()stopped the manager unconditionally even though the application created it and may share it. This PR fixes the unregistration and leaves the manager's lifecycle to its creator.Key Decisions & Assumptions
AuthXManageris created by the application and passed in viaJedisClientConfig, so Jedis does not stop it, mirroring how the config itself is owned. Reference counting and restart-on-reuse were considered and rejected as hidden lifecycle magic.destroy(), which every teardown path (close(), cluster refresh, sentinel failover, multi-dbforceDisconnect) already goes through.TrackingConnectionPoolno longer needs its ownclose()override.CopyOnWriteArrayListsince pool threads mutate it while the renewal thread iterates.Behavioral / Conceptual Changes
AuthXManager. Cluster and multi-db clients never did, so all clients are now consistent. Applications must callauthXManager.stop()after closing the last client that uses it.destroy()is skipped instead of throwing.Testing
New unit tests verify hooks are registered once and removed on destroy or close, that only the closed pool is unregistered when a manager is shared, that a sentinel
+switch-masterleaves only the new master pool registered, and that a multi-dbforceDisconnectplus recreation registers exactly once. None require a running Redis. The EntraID integration tests were not run.Notes
docs/advanced-usage.md.Note
Medium Risk
Behavior change for apps that relied on client
close()to stopAuthXManager; fixes auth renewal bugs on shared managers and failover but requires explicitauthXManager.stop().Overview
Fixes token auth (
AuthXManager) hook cleanup and lifecycle so shared managers and pool rotation (Sentinel failover, multi-db reconnect) stay reliable.ConnectionPoolno longer stopsAuthXManageronclose()— lifecycle matches application ownership (likeJedisClientConfig). CallauthXManager.stop()after the last client using it closes, or renewal threads keep running.Destroyed/closed pools unregister their post-authentication hook in
destroy()via a stable hook reference (fixes removal that failed withthis::postAuthentication).AuthXManagerusesCopyOnWriteArrayListfor hooks. Closed pools skip or swallow post-authevict()races so renewal does not fail for other pools.TrackingConnectionPooldrops a redundantclose()override.Docs: 8.1.0 behavior change and advanced-usage lifecycle note. New unit tests cover shared managers, Sentinel failover, and
forceDisconnect/recreate.Reviewed by Cursor Bugbot for commit 274858a. Bugbot is set up for automated code reviews on this repo. Configure here.