shenjiawei created HTTPASYNC-162:
------------------------------------

             Summary: 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


When RuntimException thrown 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to