Source:
public final Connection getConnection(final long hardTimeout) throws SQLException { suspendResumeLock.acquire(); final long startTime = clockSource.currentTime(); try { long timeout = hardTimeout; do { final PoolEntry poolEntry = connectionBag.borrow(timeout, MILLISECONDS); if (poolEntry == null) { break; } final long now = clockSource.currentTime(); if (poolEntry.isMarkedEvicted() || (clockSource.elapsedMillis(poolEntry.lastAccessed, now) > ALIVE_BYPASS_WINDOW_MS && !isConnectionAlive(poolEntry.connection))) { closeConnection(poolEntry, "(connection is evicted or dead)"); timeout = hardTimeout - clockSource.elapsedMillis(startTime); } else { poolEntry.lastBorrowed = now; metricsTracker.recordBorrowStats(poolEntry, startTime, now); return poolEntry.createProxyConnection(leakTask.schedule(poolEntry, houseKeepingExecutorService), now); } } while (timeout > 0L); } catch (InterruptedException e) { throw new SQLException(poolName + " - Interrupted during connection acquisition", e); } finally { suspendResumeLock.release(); } logPoolState("Timeout failure "); metricsTracker.recordConnectionTimeout(); String sqlState = null; final Throwable originalException = getLastConnectionFailure(); if (originalException instanceof SQLException) { sqlState = ((SQLException) originalException).getSQLState(); } final SQLException connectionException = new SQLTransientConnectionException(poolName + " - Connection is not available, request timed out after " + clockSource.elapsedMillis(startTime) + "ms.", sqlState, originalException); if (originalException instanceof SQLException) { connectionException.setNextException((SQLException) originalException); } throw connectionException; }

Target:
public final Connection getConnection(final long hardTimeout) throws SQLException { suspendResumeLock.acquire(); final long startTime = ClockSource.INSTANCE.currentTime(); try { long now = startTime; long timeout = hardTimeout; do { final PoolEntry poolEntry = connectionBag.borrow(timeout, MILLISECONDS); if (poolEntry == null) { break; } if (poolEntry.isValid(now)) { now = ClockSource.INSTANCE.currentTime(); metricsTracker.recordBorrowStats(startTime, now); return poolEntry.createProxyConnection(leakTask.schedule(poolEntry), now); } closeConnection(poolEntry, "(connection is evicted or dead)"); now = ClockSource.INSTANCE.currentTime(); timeout = hardTimeout - ClockSource.INSTANCE.elapsedMillis(startTime, now); } while (timeout > 0L); } catch (InterruptedException e) { throw new SQLException(poolName + " - Interrupted during connection acquisition", e); } finally { suspendResumeLock.release(); } logPoolState("Timeout failure "); metricsTracker.recordConnectionTimeout(); String sqlState = null; final Throwable originalException = getLastConnectionFailure(); if (originalException instanceof SQLException) { sqlState = ((SQLException) originalException).getSQLState(); } final SQLException connectionException = new SQLTransientConnectionException(poolName + " - Connection is not available, request timed out after " + ClockSource.INSTANCE.elapsedMillis(startTime) + "ms.", sqlState, originalException); if (originalException instanceof SQLException) { connectionException.setNextException((SQLException) originalException); } throw connectionException; }