The deprecated CommonPoolTargetSource had a set of behaviors you could define using setWhenExhaustedActionName(). The CommonsPool2TargetSource and the CommonsPool2 BaseGenericObjectPool it wraps describe "getBlockWhenExhausted" as
Returns whether to block when the borrowObject() method is invoked when the pool is exhausted
I figured that much out! What does this do otherwise?
Does the Pool get expanded as in when you set CommonsPool to "WHEN_EXHAUSTED_GROW" or does it just throw an exception? What happens?
As stated in the documentation of ObjectPool.borrowObject() behavior when exhausted is implementation depended.
The
GenericObjectPool
implementation supplied with CommonsPool2 will block ifgetBlockWhenExhausted()
is true and immediately throw aNoSuchElementException
otherwise. (as documented in GenericObjectPoolborrowObject(long borrowMaxWaitMillis))A similar behavior to "WHEN_EXHAUSTED_GROW" is not available and is most likely reached by setting maxTotal to
-1
so the pool could not exhaust at all.