public Connection borrowConnection(final long timeout, final TimeUnit unit) throws TimeoutException, ConnectionException {
        logger.debug("Borrowing connection from pool on {} - timeout in {} {} with {}", host, timeout, unit, Thread.currentThread());

        if (isClosed()) throw new ConnectionException(host.getHostUri(), host.getAddress(), "Pool is shutdown");

        // Get valid connection
        Connection availableConnection;
        try {
            // acquire lock before attempting to obtain an available connection and potentially waiting for one
            // to prevent race conditions with other threads that are releasing or creating new connections
            // otherwise signal may be called before await which would result in timeouts
            waitLock.lock();
            availableConnection = getAvailableConnection();
            if (availableConnection == null) {
                availableConnection = waitForConnection(timeout, unit);
            }
        } finally {
            waitLock.unlock();
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Borrowed {} on {} with {}", availableConnection.getConnectionInfo(), host, Thread.currentThread());
        }
        return availableConnection;
    }
The result of a connection attempt. A null value for failureCause means that the connection attempt was successful.
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java