GeezerVison is showing github.com — Unregister the MultiDb health status listener when a database is removed by kdelay · Pull Request #4791 · redis/jedis
Conversation
kdelay
commented
Oct 16, 2026
•
edited by cursor
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
MultiDbConnectionProvider.remove unregisters the health listener with a new this::onHealthStatusChange, which never equals the one addDatabaseInternal registered (each method reference is a new object), so the listener stays. Same cause as #4749.
Listeners left for the endpoint in HealthStatusManager.endpointListeners: 1 after remove, 2 after re-adding it, 3 after another remove/add. Each health event then runs onHealthStatusChange once per copy.
The fix keeps one instance for both calls, like ConnectionPool.postAuthenticationHook.
The new test fails on master (expected: <0> but was: <1>) and passes with the fix. mvn test on JDK 17: 3490 tests, 0 failures; the 1 error, TokenBasedAuthenticationUnitTests, also fails on master (500 ms await).
Note Medium Risk
Touches multi-database failover health callbacks; incorrect unregister could duplicate failover handling, but the change is a small identity fix with targeted test coverage.
Overview
Fixes a listener leak when dynamically removing a database from MultiDbConnectionProvider. remove called unregisterListener with a new this::onHealthStatusChange method reference, which never equals the listener registered in addDatabaseInternal, so the callback stayed attached and could stack on remove/add cycles (same class of bug as #4749).
The provider now keeps one healthStatusListener instance and uses it for both register and unregister. HealthStatusManager exposes a test-only getListeners(Endpoint) snapshot, plus getHealthStatusManager() on the provider. A unit test asserts the endpoint has zero listeners after remove and exactly one after re-add.
Reviewed by Cursor Bugbot for commit ed77c35. 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.
remove() passed a fresh this::onHealthStatusChange to unregisterListener,
which never matches the instance registered by addDatabaseInternal, so the
listener stayed and accumulated across remove/add cycles. Keep one instance
for both calls, as ConnectionPool does for its post-authentication hook.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-19T10:28:51.801484Z |
ed77c35 |
New commits |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4b84fce4d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MultiDbConnectionProviderDynamicEndpointUnitTest already covers add and
remove with the same mocked pool setup, so the case does not need its
own class. Package-private @VisibleForTesting accessors on the provider
and HealthStatusManager replace the reflection on their private fields.
ggivo
commented
Oct 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for the contribution!
Confirmed: this::onHealthStatusChange creates a new instance on each evaluation, so the unregister in remove() never matched. Keeping one instance fixes it and matches #4749.
Pushed 854100a on top of your branch: the test moved into MultiDbConnectionProviderDynamicEndpointUnitTest, which already covers add/remove with the same setup, and package-private @VisibleForTesting accessors (MultiDbConnectionProvider.getHealthStatusManager(), HealthStatusManager.getListeners(Endpoint)) replace the reflection on private fields. The test still fails without the fix.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|