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.
--- 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<? extends ExchangeImpl<U>> ex =
createHttp1Exchange(exchange, as);
return ex;
- } else if (secure && c== null) {
- DEBUG_LOGGER.log(Level.DEBUG, "downgrading to HTTP/1.1 ");
- CompletableFuture<? extends ExchangeImpl<U>> 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<? extends ExchangeImpl<U>> ex =
+ createHttp1Exchange(exchange, null);
+ return ex;
+ }
if (c == null) {
// no existing connection. Send request with HTTP 1 and then
// upgrade if successful