in src/main/java/org/apache/commons/pool3/impl/GenericObjectPool.java [635:659]
private void ensureIdle(final int idleCount, final boolean always) throws E {
if (idleCount < 1 || isClosed() || !always && !idleObjects.hasTakeWaiters()) {
return;
}
while (idleObjects.size() < idleCount) {
final PooledObject<T> p = create(getMaxWaitDuration());
if (PooledObject.isNull(p)) {
// Can't create objects, no reason to think another call to
// create will work. Give up.
break;
}
if (getLifo()) {
idleObjects.addFirst(p);
} else {
idleObjects.addLast(p);
}
}
if (isClosed()) {
// Pool closed while object was being added to idle objects.
// Make sure the returned object is destroyed rather than left
// in the idle object pool (which would effectively be a leak)
clear();
}
}