[Pool-425] [Pool-426] GenericObjectPool addObject does not respect maxIdle #450
+74
−1
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