From 25de82b06c831eaf03a6cd5d51ab60f178124efb Mon Sep 17 00:00:00 2001 From: Mavlushechka Date: Wed, 16 Nov 2022 13:41:50 +0500 Subject: Remove exception throwing on the createHttpUrlConnection(String spec, RequestMethod requestMethod, boolean doOutput) method --- .../a1qa/framework/utils/HttpUrlConnectionFactory.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mavlushechka/a1qa/framework/utils/HttpUrlConnectionFactory.java b/src/main/java/com/mavlushechka/a1qa/framework/utils/HttpUrlConnectionFactory.java index cfa0628..cf4d54c 100644 --- a/src/main/java/com/mavlushechka/a1qa/framework/utils/HttpUrlConnectionFactory.java +++ b/src/main/java/com/mavlushechka/a1qa/framework/utils/HttpUrlConnectionFactory.java @@ -4,6 +4,7 @@ import com.mavlushechka.a1qa.framework.constants.RequestMethod; import java.io.IOException; import java.net.HttpURLConnection; +import java.net.ProtocolException; import java.net.URL; public class HttpUrlConnectionFactory { @@ -11,10 +12,19 @@ public class HttpUrlConnectionFactory { private HttpUrlConnectionFactory() { } - public static HttpURLConnection createHttpUrlConnection(String spec, RequestMethod requestMethod, boolean doOutput) throws IOException { - HttpURLConnection httpUrlConnection = (HttpURLConnection) new URL(spec).openConnection(); + public static HttpURLConnection createHttpUrlConnection(String spec, RequestMethod requestMethod, boolean doOutput) { + HttpURLConnection httpUrlConnection; + try { + httpUrlConnection = (HttpURLConnection) new URL(spec).openConnection(); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } - httpUrlConnection.setRequestMethod(requestMethod.name()); + try { + httpUrlConnection.setRequestMethod(requestMethod.name()); + } catch (ProtocolException protocolException) { + throw new RuntimeException(protocolException); + } httpUrlConnection.setConnectTimeout(Integer.parseInt(JsonParser.parseData("config", "httpUrlConnection.connectTimeout"))); httpUrlConnection.setReadTimeout(Integer.parseInt(JsonParser.parseData("config", "httpUrlConnection.readTimeout"))); httpUrlConnection.setDoOutput(doOutput); -- cgit v1.2.3