long startWait = statistics.isEnabled() ? System.currentTimeMillis() : 0L;
if (cls.size() > 0)
{
if (shutdown.get())
throw new RetryableUnavailableException(
bundle.thePoolHasBeenShutdown(pool.getName(),
Integer.toHexString(System.identityHashCode(this))));
cl = cls.peek();
if (cl != null)
{
try
{
cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
if (statistics.isEnabled())
statistics.deltaTotalBlockingTime(System.currentTimeMillis() - startWait);
}
catch (InterruptedException ie)
{
Thread.interrupted();
long end = System.currentTimeMillis() - startWait;
throw new ResourceException(bundle.interruptedWhileRequestingConnection(end));
}
}
else
{
try
{
// No, the pool was empty, so we have to make a new one.
cl = createConnectionEventListener(subject, cri);
if (trace)
log.trace("supplying new ManagedConnection: " + cl);
verifyConnectionListener = false;
}
catch (Throwable t)
{
log.throwableWhileAttemptingGetNewGonnection(cl, t);
if (cl != null)
doDestroy(cl);
throw new ResourceException(bundle.unexpectedThrowableWhileTryingCreateConnection(cl), t);
}
}
}
else
{
try
{
cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
if (statistics.isEnabled())
statistics.deltaTotalBlockingTime(System.currentTimeMillis() - startWait);
if (shutdown.get())
throw new RetryableUnavailableException(
bundle.thePoolHasBeenShutdown(pool.getName(),
Integer.toHexString(System.identityHashCode(this))));
}
catch (InterruptedException ie)
{