GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Clear post-authentication hooks properly with pool.destroy by atakavci · Pull Request #4749 · redis/jedis

Conversation

@atakavci

@atakavci atakavci commented Sep 25, 2026 •
edited by cursor Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

ConnectionPool registers a post-authentication hook on its AuthXManager but never managed to remove it, because this::postAuthentication yields a new object on every evaluation and the list removal never matched. Stale hooks on closed pools then threw from evict() 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

  • The AuthXManager is created by the application and passed in via JedisClientConfig, 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.
  • Unregistration lives in destroy(), which every teardown path (close(), cluster refresh, sentinel failover, multi-db forceDisconnect) already goes through. TrackingConnectionPool no longer needs its own close() override.
  • The hook list becomes a CopyOnWriteArrayList since pool threads mutate it while the renewal thread iterates.

Behavioral / Conceptual Changes

  • Closing a standalone or sentinel client no longer stops the AuthXManager. Cluster and multi-db clients never did, so all clients are now consistent. Applications must call authXManager.stop() after closing the last client that uses it.
  • Sentinel master failover no longer kills token renewal for the new master pool, and closing one of several clients sharing a manager no longer breaks the others.
  • Destroyed pools are removed from the manager, so repeated pool rotation no longer accumulates hooks or fails the renewal cycle. A renewal racing with 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-master leaves only the new master pool registered, and that a multi-db forceDisconnect plus recreation registers exactly once. None require a running Redis. The EntraID integration tests were not run.

Notes

  • Behavior change is recorded in the 8.1.0 release notes and the lifecycle is documented in docs/advanced-usage.md.

Note

Medium Risk
Behavior change for apps that relied on client close() to stop AuthXManager; fixes auth renewal bugs on shared managers and failover but requires explicit authXManager.stop().

Overview
Fixes token auth (AuthXManager) hook cleanup and lifecycle so shared managers and pool rotation (Sentinel failover, multi-db reconnect) stay reliable.

ConnectionPool no longer stops AuthXManager on close() — lifecycle matches application ownership (like JedisClientConfig). Call authXManager.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 with this::postAuthentication). AuthXManager uses CopyOnWriteArrayList for hooks. Closed pools skip or swallow post-auth evict() races so renewal does not fail for other pools. TrackingConnectionPool drops a redundant close() 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@atakavci
- clear post-authentication hooks properly with pool.destroy
5f06601
@atakavci
atakavci requested a review from ggivo September 25, 2026 12:18
@atakavci atakavci self-assigned this Sep 25, 2026
@atakavci atakavci added the bug label Sep 25, 2026
atakavci added 2 commits September 25, 2026 15:18
@atakavci
Merge branch 'master' into ali/fixAuthHooks
4886468
@atakavci
- format
72d03e9
@atakavci
atakavci marked this pull request as ready for review September 25, 2026 12:26
cursor[bot]
cursor Bot reviewed Sep 25, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 72d03e9. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/redis/clients/jedis/ConnectionPool.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

atakavci added 3 commits September 29, 2026 12:24
@atakavci
- handle eviction failure against closed pool
a024d07
@atakavci
Merge branch 'master' into ali/fixAuthHooks
c0525f6
@atakavci
Merge branch 'master' into ali/fixAuthHooks
274858a
ggivo
ggivo approved these changes Sep 29, 2026
View reviewed changes

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@atakavci
atakavci merged commit ad150f4 into redis:master Sep 29, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kdelay kdelay mentioned this pull request Oct 16, 2026
Unregister the MultiDb health status listener when a database is removed #4791
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ggivo ggivo ggivo approved these changes
+1 more reviewer
@cursor cursor[bot] cursor[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@atakavci atakavci

Labels

bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@atakavci @ggivo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.