diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestTlsHandshakeTimeout.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestTlsHandshakeTimeout.java index c15d9e0cef..b763a71f50 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestTlsHandshakeTimeout.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestTlsHandshakeTimeout.java @@ -42,6 +42,7 @@ import org.apache.hc.client5.testing.SSLTestContexts; import org.apache.hc.client5.testing.tls.TlsHandshakeTimeoutServer; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.SocketConfig; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -71,6 +72,11 @@ void testTimeout(final boolean sendServerHello) throws Exception { .setConnectTimeout(5, SECONDS) .setSocketTimeout(5, SECONDS) .build()) + .setDefaultSocketConfig(SocketConfig.custom() + .setTcpKeepIdle(2) + .setTcpKeepInterval(1) + .setTcpKeepCount(5) + .build()) .setTlsSocketStrategy(new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext(), HostnameVerificationPolicy.CLIENT, NoopHostnameVerifier.INSTANCE)) .setDefaultTlsConfig(TlsConfig.custom() .setHandshakeTimeout(EXPECTED_TIMEOUT.toMillis(), MILLISECONDS) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java index 74a827e532..19edf193c0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java @@ -36,6 +36,8 @@ import java.util.Collections; import java.util.List; +import jdk.net.ExtendedSocketOptions; +import jdk.net.Sockets; import org.apache.hc.client5.http.ConnectExceptionSupport; import org.apache.hc.client5.http.DnsResolver; import org.apache.hc.client5.http.SchemePortResolver; @@ -58,7 +60,6 @@ import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.io.Closer; -import org.apache.hc.core5.io.SocketSupport; import org.apache.hc.core5.net.NamedEndpoint; import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.TimeValue; @@ -318,13 +319,13 @@ private static void configureSocket(final Socket socket, final SocketConfig sock socket.setSoLinger(true, linger); } if (socketConfig.getTcpKeepIdle() > 0) { - SocketSupport.setOption(socket, SocketSupport.TCP_KEEPIDLE, socketConfig.getTcpKeepIdle()); + Sockets.setOption(socket, ExtendedSocketOptions.TCP_KEEPIDLE, socketConfig.getTcpKeepIdle()); } if (socketConfig.getTcpKeepInterval() > 0) { - SocketSupport.setOption(socket, SocketSupport.TCP_KEEPINTERVAL, socketConfig.getTcpKeepInterval()); + Sockets.setOption(socket, ExtendedSocketOptions.TCP_KEEPINTERVAL, socketConfig.getTcpKeepInterval()); } if (socketConfig.getTcpKeepCount() > 0) { - SocketSupport.setOption(socket, SocketSupport.TCP_KEEPCOUNT, socketConfig.getTcpKeepCount()); + Sockets.setOption(socket, ExtendedSocketOptions.TCP_KEEPCOUNT, socketConfig.getTcpKeepCount()); } } diff --git a/pom.xml b/pom.xml index e15b97926f..d841a29aa3 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 1.21.3 2.10.1 5.3 - javax.net.ssl.SSLEngine,javax.net.ssl.SSLParameters,java.nio.ByteBuffer,java.nio.CharBuffer + javax.net.ssl.SSLEngine,javax.net.ssl.SSLParameters,java.nio.ByteBuffer,java.nio.CharBuffer,jdk.net.ExtendedSocketOptions,jdk.net.Sockets 1.27.1 1.5.7-4