[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    [httpcomponents-client] 01/03: Use try-with-resources in examples
From:       olegk () apache ! org
Date:       2020-03-07 10:12:10
Message-ID: 20200307101209.B60018DACC () gitbox ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 56ef8b8642ab334cd0b35144c374295150af2bb2
Author: Oleg Kalnichevski <olegk@apache.org>
AuthorDate: Mon Feb 24 12:07:55 2020 +0100

    Use try-with-resources in examples
---
 .../java/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 e237a58..1d7d4fe 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();
         }
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic