From 69e158d77d24bbd0a9b6900d406aba266db5ccb3 Mon Sep 17 00:00:00 2001 From: Codegass Date: Sun, 9 Oct 2022 05:52:32 -0400 Subject: [PATCH] Refactor TestHttp.testHttpclient to avoid the Exception Suppression (#6733) * Refactor TestHttp.testHttpclient to avoid the Exception Suppression * Remove the unnecessary import --- .../cloudstack/storage/test/TestHttp.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 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 43a24768918..339f9f603f4 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 java.io.OutputStream; 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; @@ -41,7 +40,7 @@ import junit.framework.Assert; 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 +61,9 @@ public class TestHttp extends AbstractTestNGSpringContextTests { 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(); } }