Fix Connection Close Exception Handling for commons-pool2 2.13.1#4439
Open
atakavci wants to merge 4 commits intoredis:masterfrom
Open
Fix Connection Close Exception Handling for commons-pool2 2.13.1#4439atakavci wants to merge 4 commits intoredis:masterfrom
atakavci wants to merge 4 commits intoredis:masterfrom
Conversation
…apache commons in version 2.13.1 - comment
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Jedis’ connection-close error handling to accommodate a behavior change in commons-pool2 2.13.1 where GenericObjectPool.invalidateObject() attempts to create a replacement instance, potentially throwing a secondary exception during cleanup.
Changes:
- Refactors
MultiDbCommandExecutor.handleExecuteCommand()to preserve the original command exception while suppressing close-time exceptions. - Adds helper methods (
acquireConnection,isFailDuringFailover,closeAndSuppress) to structure the new close/suppression behavior. - Updates
UnavailableConnectionTestto tolerate the new pool invalidation behavior duringclose().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/main/java/redis/clients/jedis/mcf/MultiDbCommandExecutor.java |
Adds close-time exception suppression so command failures are not replaced by cleanup failures. |
src/test/java/redis/clients/jedis/UnavailableConnectionTest.java |
Adjusts integration test expectations around close() under the new pool invalidation semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/redis/clients/jedis/UnavailableConnectionTest.java
Outdated
Show resolved
Hide resolved
src/main/java/redis/clients/jedis/mcf/MultiDbCommandExecutor.java
Outdated
Show resolved
Hide resolved
src/main/java/redis/clients/jedis/mcf/MultiDbCommandExecutor.java
Outdated
Show resolved
Hide resolved
src/main/java/redis/clients/jedis/mcf/MultiDbCommandExecutor.java
Outdated
Show resolved
Hide resolved
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
Here the bump attempt for org.apache.commons:commons-pool2 from 2.12.1 to 2.13.1.
Those tests failing during connection close is due to behavioral change - the way invalidateObject tries addObject - in GenericObjectPools implementation.
This PR suppresses those exceptions during connection close to accommodate the behavioral change.
Context
Starting with
commons-pool22.13.1,GenericObjectPool.invalidateObject()attempts to replace invalidated instances, which can fail whenConnectionFactory.makeObject()throws an exception. This change ensures the original exception is preserved while suppressing any secondary exceptions from connection cleanup.I am willing to follow up with the commons-pool team to explore whether a built-in option or a solution can be introduced in the pool implementation. Will update here any progress with commons-pool team.
Changes
MultiDbCommandExecutor.handleExecuteCommand()to properly suppress exceptions duringconnection.close()closeAndSuppress()helper to capture initial exceptions and suppress close-time exceptionsUnavailableConnectionTestto handle expected exception from pool invalidation