You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (Jira)" <ji...@apache.org> on 2020/06/04 13:58:00 UTC

[jira] [Resolved] (HTTPASYNC-162) Client will be shutdown when throw runtimexception in FutureCallback.cancelled

     [ https://issues.apache.org/jira/browse/HTTPASYNC-162?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPASYNC-162.
-----------------------------------------
    Resolution: Not A Problem

> Client will be shutdown when throw runtimexception in FutureCallback.cancelled
> ------------------------------------------------------------------------------
>
>                 Key: HTTPASYNC-162
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-162
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>    Affects Versions: 4.1.4
>         Environment: Linux centos + JDK8 
>            Reporter: shenjiawei
>            Priority: Major
>
> When RuntimException thrown from FutureCallback.cancelled, the client will be shutdown immediately。
> {code:java}
> public static void main(String[] args) throws Exception {
>     RequestConfig.Builder rconfig_builder = RequestConfig.custom();
>     rconfig_builder.setConnectionRequestTimeout(10);
>     rconfig_builder.setConnectTimeout(10);
>     rconfig_builder.setSocketTimeout(10);
>     HttpAsyncClientBuilder builder = HttpAsyncClientBuilder.create();
>     builder.setDefaultRequestConfig(rconfig_builder.build());
>     CloseableHttpAsyncClient client = builder.build();
>     client.start();
>     client.execute(new HttpGet("http://unknow.cc"), new FutureCallback<HttpResponse>() {
>         public void completed(HttpResponse result) {
>             System.out.println("Completed...");
>         }
>         public void failed(Exception ex) {
> 	    System.out.println("Failed...");
> 	    throw new RuntimeException();
> 	}
> 	public void cancelled() {
> 	    System.out.println("Cancel...");
>             throw new RuntimeException();
> 	}
>     });
>     while (client.isRunning()) {
>         System.out.println("Running...");
>         Thread.sleep(5000);
>     }
>     System.out.println("Shutdown...");
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org