From 3025e06faa8f4ed28ee00274f9c3e9538dd8157c Mon Sep 17 00:00:00 2001 From: Codegass Date: Mon, 12 Sep 2022 14:36:53 -0400 Subject: [PATCH 1/2] Refactor TestHttp.testHttpclient to avoid the Exception Suppression --- .../cloudstack/storage/test/TestHttp.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java index 43a247689184..4a38b793087c 100644 --- a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java +++ b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java @@ -41,7 +41,7 @@ public class TestHttp extends AbstractTestNGSpringContextTests { @Test @Parameters("template-url") - public void testHttpclient(String templateUrl) { + public void testHttpclient(String templateUrl) throws IOException { final HttpHead method = new HttpHead(templateUrl); final DefaultHttpClient client = new DefaultHttpClient(); @@ -62,20 +62,9 @@ public void testHttpclient(String templateUrl) { output = new BufferedOutputStream(new FileOutputStream(localFile)); entity.writeTo(output); - } catch (final ClientProtocolException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } finally { - try { - if (output != null) { - output.close(); - } - } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (output != null) { + output.close(); } } From f1aff02c33c75187442eb4e0b3fa370ba26a1563 Mon Sep 17 00:00:00 2001 From: Codegass Date: Mon, 12 Sep 2022 14:50:46 -0400 Subject: [PATCH 2/2] Remove the unnecessary import --- .../test/java/org/apache/cloudstack/storage/test/TestHttp.java | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java index 4a38b793087c..339f9f603f42 100644 --- a/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java +++ b/engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java @@ -26,7 +26,6 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.impl.client.DefaultHttpClient;