The fix for POOL-425 included in the 2.13.0 release introduced a regression
that makes addObject no-op when maxIdle is set to a negative value (no
limit).  The POOL-425 fix also failed to account for a race condition
reported in POOL-426.

I have created a PR https://github.com/apache/commons-pool/pull/452
that addresses
both issues.  To avoid the race condition, I had to add synchronization to
addObject.  I tried several ways to avoid the race by modifying create (as
suggested by Raju Gupta, the OP for POOL-426) but I could not find a way to
do that safely without introducing other issues.  I don't see the added
sync in addObject as critical as this method is not used in hot code paths
internally and the lock that it acquires is the same lock that create will
subsequently acquire if it proceeds to add an object.

The regression could be addressed in a simpler way by just fixing the error
in the code (failure to check for negative maxIdle).   If there are any
doubts about the PR above, I am happy to make that simple change.  In any
case, we should patch this quickly as it will likely break some apps that
use addObject with maxIdle unilimited.

Thanks, all, and sorry for my mistake in the POOL-425 fix.

Phil

Reply via email to