private Connection getAvailableConnection() {
        Connection available = null;

        // remove head of queue until we can borrow a connection or the queue is empty
        Connection head = availableConnections.poll();
        while (head != null) {
            // try to borrow connection
            if (!head.isDead() && !head.isBorrowed().get() && head.isBorrowed().compareAndSet(false, true)) {
                available = head;
                break;
            }
            head = availableConnections.poll();
        }

        if (available == null && connections.size() < maxPoolSize) {
            considerNewConnection();
        }

        return available;
    }
Get an available connection from the pool. Also triggers consideration of a new connection if the least-used
connection has hit the usage maximum or no valid connection could be retrieved from the pool.

@return an available connection from the pool. Returns null if no valid connection could be retrieved from the
pool.
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java