@Override
                    public void completed(final AsyncConnectionEndpoint connectionEndpoint) {
                        if (connectionEndpoint.isConnected()) {
                            resultFuture.completed(connectionEndpoint);
                        } else {
                            final Future<AsyncConnectionEndpoint> connectFuture = manager.connect(
                                    connectionEndpoint,
                                    getConnectionInitiator(),
                                    connectTimeout,
                                    tlsConfig,
                                    clientContext,
                                    new FutureCallback<AsyncConnectionEndpoint>() {

                                        @Override
                                        public void completed(final AsyncConnectionEndpoint result) {
                                            resultFuture.completed(result);
                                        }

                                        @Override
                                        public void failed(final Exception ex) {
                                            try {
                                                Closer.closeQuietly(connectionEndpoint);
                                                manager.release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS);
                                            } finally {
                                                resultFuture.failed(ex);
                                            }
                                        }

                                        @Override
                                        public void cancelled() {
                                            try {
                                                Closer.closeQuietly(connectionEndpoint);
                                                manager.release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS);
                                            } finally {
                                                resultFuture.cancel(true);
                                            }
                                        }

                                    });
                            resultFuture.setDependency(connectFuture);
                        }
                    }
Minimal implementation of {@link CloseableHttpAsyncClient}. This client is
optimized for HTTP/1.1 and HTTP/2 message transport and does not support
advanced HTTP protocol functionality such as request execution via a proxy,
state management, authentication and request redirects.
<p>
Concurrent message exchanges executed by this client will get assigned to
separate connections leased from the connection pool.
</p>

@since 5.0
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java