From b59a02f69f7bf785945462c0c17a51aa35360a75 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Thu, 12 Dec 2024 08:01:26 +0100 Subject: [PATCH] SNOW-1739611: Verify timeouts are correctly set on http client --- .../net/snowflake/client/core/HttpUtilLatestIT.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/net/snowflake/client/core/HttpUtilLatestIT.java b/src/test/java/net/snowflake/client/core/HttpUtilLatestIT.java index 00c318227..a31753103 100644 --- a/src/test/java/net/snowflake/client/core/HttpUtilLatestIT.java +++ b/src/test/java/net/snowflake/client/core/HttpUtilLatestIT.java @@ -10,6 +10,7 @@ import java.net.SocketTimeoutException; import java.time.Duration; import net.snowflake.client.category.TestTags; +import org.apache.http.client.methods.Configurable; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.hamcrest.CoreMatchers; @@ -38,8 +39,18 @@ public void shouldOverrideConnectionAndSocketTimeouts() { HttpUtil.setConnectionTimeout(100); HttpUtil.setSocketTimeout(200); + assertEquals(Duration.ofMillis(100), HttpUtil.getConnectionTimeout()); + assertEquals(Duration.ofMillis(200), HttpUtil.getSocketTimeout()); + CloseableHttpClient httpClient = HttpUtil.getHttpClient(new HttpClientSettingsKey(OCSPMode.INSECURE)); + + assertEquals(Duration.ofMillis(100), HttpUtil.getConnectionTimeout()); + assertEquals(Duration.ofMillis(200), HttpUtil.getSocketTimeout()); + + assertEquals(100, ((Configurable) httpClient).getConfig().getConnectTimeout()); + assertEquals(200, ((Configurable) httpClient).getConfig().getSocketTimeout()); + try { httpClient.execute(new HttpGet(HANG_WEBSERVER_ADDRESS)); fail("Request should fail with exception");