code: public Connection getConnection(final long hardTimeout) throws SQLException
     {
        suspendResumeLock.acquire();
        final long startTime = currentTime();
  
        try {
           long timeout = hardTimeout;
           do {
              PoolEntry poolEntry = connectionBag.borrow(timeout, MILLISECONDS);
              if (poolEntry == null) {
                 break; // We timed out... break and throw exception
              }
  
              final long now = currentTime();
              if (poolEntry.isMarkedEvicted() || (elapsedMillis(poolEntry.lastAccessed, now) > aliveBypassWindowMs && !isConnectionAlive(poolEntry.connection))) {
                 closeConnection(poolEntry, poolEntry.isMarkedEvicted() ? EVICTED_CONNECTION_MESSAGE : DEAD_CONNECTION_MESSAGE);
                 timeout = hardTimeout - elapsedMillis(startTime);
              }
              else {
                 metricsTracker.recordBorrowStats(poolEntry, startTime);
                 return poolEntry.createProxyConnection(leakTaskFactory.schedule(poolEntry), now);
              }
           } while (timeout > 0L);
  
           metricsTracker.recordBorrowTimeoutStats(startTime);
           throw createTimeoutException(startTime);
        }
        catch (InterruptedException e) {
           Thread.currentThread().interrupt();
           throw new SQLException(poolName + " - Interrupted during connection acquisition", e);
        }
        finally {
           suspendResumeLock.release();
        }
     }
docs: Get a connection from the pool, or timeout after the specified number of milliseconds.
  
  @param hardTimeout the maximum time to wait for a connection from the pool
  @return a java.sql.Connection instance
  @throws SQLException thrown if a timeout occurs trying to obtain a connection