--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java Fri Jul 27 12:16:01 2018 +0100
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java Mon Aug 27 11:48:07 2018 +0100
@@ -35,6 +35,7 @@
import java.net.ConnectException;
import java.net.CookieHandler;
import java.net.ProxySelector;
+import java.net.http.HttpConnectTimeoutException;
import java.net.http.HttpTimeoutException;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
@@ -47,6 +48,7 @@
import java.security.AccessController;
import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedAction;
+import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@@ -154,6 +156,7 @@
}
private final CookieHandler cookieHandler;
+ private final Duration connectTimeout;
private final Redirect followRedirects;
private final Optional<ProxySelector> userProxySelector;
private final ProxySelector proxySelector;
@@ -278,6 +281,7 @@
facadeRef = new WeakReference<>(facadeFactory.createFacade(this));
client2 = new Http2ClientImpl(this);
cookieHandler = builder.cookieHandler;
+ connectTimeout = builder.connectTimeout;
followRedirects = builder.followRedirects == null ?
Redirect.NEVER : builder.followRedirects;
this.userProxySelector = Optional.ofNullable(builder.proxy);
@@ -547,6 +551,10 @@
throw new IllegalArgumentException(msg, throwable);
} else if (throwable instanceof SecurityException) {
throw new SecurityException(msg, throwable);
+ } else if (throwable instanceof HttpConnectTimeoutException) {
+ HttpConnectTimeoutException hcte = new HttpConnectTimeoutException(msg);
+ hcte.initCause(throwable);
+ throw hcte;
} else if (throwable instanceof HttpTimeoutException) {
throw new HttpTimeoutException(msg);
} else if (throwable instanceof ConnectException) {
@@ -1124,6 +1132,11 @@
}
@Override
+ public Optional<Duration> connectTimeout() {
+ return Optional.ofNullable(connectTimeout);
+ }
+
+ @Override
public Optional<ProxySelector> proxy() {
return this.userProxySelector;
}