[Pool-425] [Pool-426] GenericObjectPool addObject does not respect maxIdle#450
Closed
rajucomp wants to merge 3 commits intoapache:masterfrom
rajucomp:master
Closed
[Pool-425] [Pool-426] GenericObjectPool addObject does not respect maxIdle#450rajucomp wants to merge 3 commits intoapache:masterfrom rajucomp:master
rajucomp wants to merge 3 commits intoapache:masterfrom
rajucomp:master
Conversation
Author
|
@garydgregory @psteitz Requesting critical review for the fix for POOL-425. Thanks! |
ruanLN
reviewed
Dec 16, 2025
Comment on lines
+516
to
+520
| int localMaxIdle = getMaxIdle(); | ||
| if (localMaxIdle < 0) { | ||
| localMaxIdle = Integer.MAX_VALUE; | ||
| } | ||
| final int maxCapacity = Math.min(localMaxTotal, localMaxIdle); |
There was a problem hiding this comment.
This will cause issues if maxIdle is set to zero, making it impossible to create new objects in the pool.
Since the method is private we can verify it is only used during the borrow, where it is not added to the idle objects, and on addObject, where it is.
the addObject method should be checking the idle object limit isn't being crossed.
Author
|
Fixed in #452 |
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.
Thanks for your contribution to Apache Commons! Your help is appreciated!
Before you push a pull request, review this list:
mvn; that'smvnon the command line by itself.Problem/Bug Description
When the pool's
addObject()method is called to pre-load the pool with idle objects, the current implementation only validates againstmaxTotal(the maximum total number of objects that can exist in the pool, including both active and idle objects) to prevent exceeding the configured maximum. However, it does not validate againstmaxIdle(the maximum number of idle objects allowed in the pool).This validation gap can result in the pool creating more idle objects than the configured
maxIdlelimit allows, which violates the pool's configuration contract.Fix
The fix ensures both
maxTotalandmaxIdlevalues are properly compared, and the pool uses the minimum of these two values as the effective limit when deciding whether to add new objects. This ensures the pool respects whichever limit is lower and prevents violating either configuration constraint.Related JIRA Issue
This fix addresses POOL-425: GenericObjectPool addObject does not respect maxIdle
Checklist
maxTotalandmaxIdle