From 4865d2875a71a3f804dd9b84a0f02b4b4f734173 Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 16:06:18 +0100 Subject: [PATCH 1/2] update(UnirestWrapper): Add 10 second socket timeout --- src/main/java/seatsio/util/UnirestWrapper.java | 4 +++- src/test/java/seatsio/ErrorHandlingTest.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/seatsio/util/UnirestWrapper.java b/src/main/java/seatsio/util/UnirestWrapper.java index 3403b11c..5cbff59d 100644 --- a/src/main/java/seatsio/util/UnirestWrapper.java +++ b/src/main/java/seatsio/util/UnirestWrapper.java @@ -9,7 +9,9 @@ public class UnirestWrapper { - private static UnirestInstance unirest = new UnirestInstance(new Config().concurrency(200, 200)); + private static UnirestInstance unirest = new UnirestInstance(new Config() + .socketTimeout(10000) + .concurrency(200, 200)); private int maxRetries = 5; private final String secretKey; diff --git a/src/test/java/seatsio/ErrorHandlingTest.java b/src/test/java/seatsio/ErrorHandlingTest.java index dcd37bf4..fd005d3a 100644 --- a/src/test/java/seatsio/ErrorHandlingTest.java +++ b/src/test/java/seatsio/ErrorHandlingTest.java @@ -1,5 +1,6 @@ package seatsio; +import kong.unirest.UnirestException; import org.junit.jupiter.api.Test; import seatsio.util.UnirestWrapper; @@ -31,4 +32,13 @@ public void testWeirdError() { assertThat(e.getMessage()).contains("Error while executing GET unknownProtocol:///charts/unexistingChart"); assertThat(e.errors).isNull(); } + + @Test + public void testSocketTimeout() { + SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/delay/5").socketTimeout(1000))); + assertThat(e.getMessage()).contains("Error while executing GET https://httpbin.seatsio.net/delay/5"); + assertThat(e.getCause()).isInstanceOf(UnirestException.class); + assertThat(e.getCause().getCause()).isInstanceOf(java.net.SocketTimeoutException.class); + assertThat(e.errors).isNull(); + } } From f859e5d4a0cb61ca09e190ed053ecddc29bc5cad Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 16:10:13 +0100 Subject: [PATCH 2/2] tiny timeout --- src/test/java/seatsio/ErrorHandlingTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/seatsio/ErrorHandlingTest.java b/src/test/java/seatsio/ErrorHandlingTest.java index fd005d3a..0297e9eb 100644 --- a/src/test/java/seatsio/ErrorHandlingTest.java +++ b/src/test/java/seatsio/ErrorHandlingTest.java @@ -35,7 +35,7 @@ public void testWeirdError() { @Test public void testSocketTimeout() { - SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/delay/5").socketTimeout(1000))); + SeatsioException e = assertThrows(SeatsioException.class, () -> new UnirestWrapper("secretKey", null).stringResponse(get("https://httpbin.seatsio.net/delay/5").socketTimeout(10))); assertThat(e.getMessage()).contains("Error while executing GET https://httpbin.seatsio.net/delay/5"); assertThat(e.getCause()).isInstanceOf(UnirestException.class); assertThat(e.getCause().getCause()).isInstanceOf(java.net.SocketTimeoutException.class);