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 2019/07/06 09:17:00 UTC

[jira] [Commented] (HTTPASYNC-150) execute(HttpUriRequest, HttpUriRequest) does not use route planner

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

Oleg Kalnichevski commented on HTTPASYNC-150:
---------------------------------------------

This code snippet works fine for me. The problem appears to be related to your custom route planner.

{code:java}
final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
        .setRoutePlanner(new DefaultRoutePlanner(DefaultSchemePortResolver.INSTANCE) {

            @Override
            public HttpRoute determineRoute(
                    final HttpHost host,
                    final HttpRequest request,
                    final HttpContext context) throws HttpException {
                HttpRoute route = super.determineRoute(host, request, context);
                System.out.println("Request route " + route);
                return route;
            }
        })
        .build();
try {
    httpclient.start();
    HttpGet request = new HttpGet("http://httpbin.org/get");
    Future<HttpResponse> future = httpclient.execute(request, null);
    HttpResponse response = future.get();
    System.out.println("Response: " + response.getStatusLine());
    System.out.println("Shutting down");
} finally {
    httpclient.close();
}
{code}

stdout>
{noformat}
Request route {}->http://httpbin.org:80
Response: HTTP/1.1 200 OK
Shutting down
{noformat}

Oleg

> execute(HttpUriRequest, HttpUriRequest) does not use route planner
> ------------------------------------------------------------------
>
>                 Key: HTTPASYNC-150
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-150
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>            Reporter: Priyanga C. Gunaratne
>            Priority: Major
>
> Calling the {{execute(HttpUriRequest, HttpUriRequest)}} method in the {{CloseableHttpAsyncClient}} class does not appear to call the route planner. The route planner was configured using the {{HttpAsyncClientBuilder.setRoutePlanner}} method.
> Library and version are {{org.apache.httpcomponents:httpasyncclient:4.1.4}}.
> Is this a bug or expected behaviour? The set of examples do not appear to cover using a route planner with the async client.
> The error message is {{"HTTP host may not be null"}} and some lines from the stack trace:
> {noformat}
> {"methodName":"notNull","fileName":"Args.java","lineNumber":54,"className":"org.apache.http.util.Args","nativeMethod":false},
> {"methodName":"create","fileName":"HttpAsyncMethods.java","lineNumber":72,"className":"org.apache.http.nio.client.methods.HttpAsyncMethods","nativeMethod":false},
> {"methodName":"execute","fileName":"CloseableHttpAsyncClient.java","lineNumber":76,"className":"org.apache.http.impl.nio.client.CloseableHttpAsyncClient","nativeMethod":false},
> {"methodName":"execute","fileName":"CloseableHttpAsyncClient.java","lineNumber":108,"className":"org.apache.http.impl.nio.client.CloseableHttpAsyncClient","nativeMethod":false},
> {"methodName":"execute","fileName":"CloseableHttpAsyncClient.java","lineNumber":92,"className":"org.apache.http.impl.nio.client.CloseableHttpAsyncClient","nativeMethod":false},
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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