s-sanjay opened a new pull request, #346:
URL: https://github.com/apache/commons-pool/pull/346

   We ran into a issue in production when using commond-dbcp where a single 
thread will deadlock itself while connecting to mysql due to validation failure 
on create. We root caused this to a scenario where the thread will wait forever 
for object in the queue but no object is created. The code folow is as follows.
    
   In `GenericObjectPool`, inside the function `borrowObject`, If 
`borrowMaxWaitDuration` is negative and there is not a single created object 
(borrowed + idle), the caller would block indefinitely, especially in 
single-threaded scenarios, leading to a deadlock. This can happen because even 
though we try to create an object during borrow, create could return null if 
either `getMaxTotal()` returns 0 or creation fails because of various reasons ( 
eg: validateObject is false with `getTestOnCreate()` )
   
   - Added a check to throw a `NoSuchElementException` when there is not a 
single created (free + borrowed) object, preventing deadlocks.
   - Introduced a corresponding test case `testWhenNoObjectDoesNotBlock` in 
`TestGenericObjectPool` to validate the behavior.
   
   This ensures that the pool correctly fails to borrow objects when nothing is 
created, even with blocking enabled.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to