private CompletableFuture<AsyncConnection> getConn() {
    CompletableFuture<AsyncConnection> f = future.get();
    if (f != null) {
      return f;
    }
    for (;;) {
      if (future.compareAndSet(null, new CompletableFuture<>())) {
        CompletableFuture<AsyncConnection> toComplete = future.get();
        addListener(ConnectionFactory.createAsyncConnection(getConf()), (conn, error) -> {
          if (error != null) {
            toComplete.completeExceptionally(error);
            // we need to reset the future holder so we will get a chance to recreate an async
            // connection at next try.
            future.set(null);
            return;
          }
          toComplete.complete(conn);
        });
        return toComplete;
      } else {
        f = future.get();
        if (f != null) {
          return f;
        }
      }
    }
  }
For the example we're just using one qualifier.
hbase-examples/src/main/java/org/apache/hadoop/hbase/client/example/AsyncClientExample.java