From 56ef8b8642ab334cd0b35144c374295150af2bb2 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Mon, 24 Feb 2020 12:07:55 +0100 Subject: [PATCH] Use try-with-resources in examples --- .../org/apache/hc/client5/http/examples/AsyncQuickStart.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java index e237a5825..1d7d4fec1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java @@ -49,8 +49,7 @@ import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder; public class AsyncQuickStart { public static void main (final String[] args) throws Exception { - final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault(); - try { + try (final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault()) { // Start the client httpclient.start(); @@ -143,8 +142,6 @@ public class AsyncQuickStart { }); latch2.await(); - } finally { - httpclient.close(); } }