From f1fdd9947297c9fa7c4f7f983a445c1481747d7e Mon Sep 17 00:00:00 2001 From: Gus Narea Date: Mon, 23 Nov 2020 21:44:24 +0000 Subject: [PATCH] fix: Treat HTTP endpoint timeouts as server connection exceptions (#83) --- src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt b/src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt index 103a1b1..ebb23e1 100644 --- a/src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt +++ b/src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt @@ -46,7 +46,6 @@ import tech.relaycorp.relaynet.messages.control.PrivateNodeRegistrationRequest import tech.relaycorp.relaynet.wrappers.x509.Certificate import java.io.EOFException import java.io.IOException -import java.net.SocketException import java.net.UnknownHostException import java.security.MessageDigest import java.security.PublicKey @@ -246,12 +245,10 @@ public class PoWebClient internal constructor( } body = requestBody } - } catch (exc: SocketException) { - // Java on macOS throws a SocketException but all other platforms throw a - // ConnectException (a subclass of SocketException) - throw ServerConnectionException("Failed to connect to $url", exc) } catch (exc: UnknownHostException) { throw ServerConnectionException("Failed to resolve DNS for $baseURL", exc) + } catch (exc: IOException) { + throw ServerConnectionException("Failed to connect to $url", exc) } if (response.status.value in 200..299) {