# HG changeset patch # User michaelm # Date 1513347983 0 # Node ID 087a6b6d4955bcac8084959171f0a127b1c1ba80 # Parent 10cefe168d6dd328615ee074c1ebe2855e8631ac changeset: 48573:3f9dda0428dc branch: http-client-branch tag: tip user: michaelm date: Fri Dec 15 14:19:51 2017 +0000 summary: http-client-branch: Fixed problem with h2c connection reuse. diff -r 10cefe168d6d -r 087a6b6d4955 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java Fri Dec 15 13:35:56 2017 +0300 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java Fri Dec 15 14:26:23 2017 +0000 @@ -98,12 +98,12 @@ HttpConnection connection) { DEBUG_LOGGER.log(Level.DEBUG, "handling HTTP/2 connection creation result"); + boolean secure = exchange.request().secure(); if (t != null) { DEBUG_LOGGER.log(Level.DEBUG, "handling HTTP/2 connection creation failed: %s", (Object)t); t = Utils.getCompletionCause(t); - boolean secure = exchange.request().secure(); if (t instanceof Http2Connection.ALPNException) { Http2Connection.ALPNException ee = (Http2Connection.ALPNException)t; AbstractAsyncSSLConnection as = ee.getConnection(); @@ -111,17 +111,18 @@ CompletableFuture> ex = createHttp1Exchange(exchange, as); return ex; - } else if (secure && c== null) { - DEBUG_LOGGER.log(Level.DEBUG, "downgrading to HTTP/1.1 "); - CompletableFuture> ex = - createHttp1Exchange(exchange, null); - return ex; } else { DEBUG_LOGGER.log(Level.DEBUG, "HTTP/2 connection creation failed " + "with unexpected exception: %s", (Object)t); return CompletableFuture.failedFuture(t); } } + if (secure && c== null) { + DEBUG_LOGGER.log(Level.DEBUG, "downgrading to HTTP/1.1 "); + CompletableFuture> ex = + createHttp1Exchange(exchange, null); + return ex; + } if (c == null) { // no existing connection. Send request with HTTP 1 and then // upgrade if successful