hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCORE-490) concurrent bug when invoke future.cancel
Date Tue, 19 Sep 2017 17:41:00 GMT

    [ https://issues.apache.org/jira/browse/HTTPCORE-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16172068#comment-16172068
] 

Oleg Kalnichevski commented on HTTPCORE-490:
--------------------------------------------

Could you please test this patch and let me know if it resolves the problem for you?

https://github.com/ok2c/httpcore/commit/41d374cd352d71b725b60ea1c340b01c774eab58

Oleg

> concurrent bug when invoke future.cancel
> ----------------------------------------
>
>                 Key: HTTPCORE-490
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-490
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.4.7
>            Reporter: wenqi.huang
>            Assignee: Oleg Kalnichevski
>             Fix For: 4.4.8
>
>
> The following code has a bug that the third http invoke will never respond. pay attention
to the parameters setted in the code like socketTimeout,maxConnPerRoute,maxConnTotal, etc.
and the url invoked must block for 5 seconds at server side(in other worlds, sleep for 5 seconds.)
>  
> {code:java}
> public class AsyncHttpClientTest {
>     public static void main(String[] args) throws InterruptedException {
>         //please attention to the socketTimeout,maxConnPerRoute,maxConnTotal
>         CloseableHttpAsyncClient c = HttpAsyncClientBuilder.create()
>                 .setDefaultRequestConfig(RequestConfig.custom().setSocketTimeout(4000).build())
>                 .setMaxConnPerRoute(1).setMaxConnTotal(1).build();
>         c.start();
>         //this url will block for 5 seconds at server side.
>         HttpGet httpGet = new HttpGet("http://localhost:8778/someUrlWillBlockForFiveSecondsAtServerSide");
>         Future f1 = execute(httpGet, c);
>         Future f2 = execute(httpGet, c);
>         //this http invoke will never success or fail.
>         Future f3 = execute(httpGet, c);
>         System.out.println("begin");
>         Thread.sleep(1000);
>         f1.cancel(true);
>         f2.cancel(true);
>     }
>     private static Future execute(HttpGet httpGet, CloseableHttpAsyncClient c){
>         return c.execute(httpGet, new FutureCallback<HttpResponse>() {
>             @Override
>             public void completed(HttpResponse result) {
>                 String ret = null;
>                 try {
>                     ret = IOUtils.toString(result.getEntity().getContent());
>                 } catch (IOException e) {
>                     e.printStackTrace();
>                 }
>                 System.out.println("completed:"+ret);
>             }
>             @Override
>             public void failed(Exception ex) {
>                 System.out.println("failed");
>                 ex.printStackTrace();
>             }
>             @Override
>             public void cancelled() {
>                 System.out.println("cancelled");
>             }
>         });
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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


Mime
View raw message