src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
changeset 51364 31d9e82b2e64
parent 51231 1d8b1d4eae6a
child 52499 768b1c612100
child 56868 67c7659ecda5
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java	Wed Aug 08 15:51:08 2018 -0700
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java	Thu Aug 09 11:23:12 2018 +0100
@@ -353,7 +353,8 @@
 
     // Requires TLS handshake. So, is really async
     static CompletableFuture<Http2Connection> createAsync(HttpRequestImpl request,
-                                                          Http2ClientImpl h2client) {
+                                                          Http2ClientImpl h2client,
+                                                          Exchange<?> exchange) {
         assert request.secure();
         AbstractAsyncSSLConnection connection = (AbstractAsyncSSLConnection)
         HttpConnection.getConnection(request.getAddress(),
@@ -361,7 +362,12 @@
                                      request,
                                      HttpClient.Version.HTTP_2);
 
-        return connection.connectAsync()
+        // Expose the underlying connection to the exchange's aborter so it can
+        // be closed if a timeout occurs.
+        exchange.connectionAborter.connection(connection);
+
+        return connection.connectAsync(exchange)
+                  .thenCompose(unused -> connection.finishConnect())
                   .thenCompose(unused -> checkSSLConfig(connection))
                   .thenCompose(notused-> {
                       CompletableFuture<Http2Connection> cf = new MinimalFuture<>();