long startWait = System.currentTimeMillis();
if (getAvailableConnections() > 0)
{
if (shutdown.get())
throw new RetryableUnavailableException("The pool has been shutdown");
cl = cls.peek();
if (cl != null)
{
try
{
cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
}
catch (InterruptedException ie)
{
long end = System.currentTimeMillis() - startWait;
throw new ResourceException("Interrupted while requesting connection! Waited " + end + " ms");
}
}
else
{
try
{
// No, the pool was empty, so we have to make a new one.
cl = createConnectionEventListener(subject, cri);
// Started is atomic, so pool filler won't be scheduled twice
if (!started.getAndSet(true))
{
if (poolConfiguration.getMinSize() > 0)
PoolFiller.fillPool(this);
}
if (trace)
log.trace("supplying new ManagedConnection: " + cl);
verifyConnectionListener = false;
}
catch (Throwable t)
{
log.warn("Throwable while attempting to get a new connection: " + cl, t);
JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying " +
"to create a connection: " + cl, t);
}
}
}
else
{
try
{
cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
if (shutdown.get())
throw new RetryableUnavailableException("The pool has been shutdown");
}
catch (InterruptedException ie)
{
if (!poolConfiguration.isUseFastFail())
{