Carsten Reckord created HTTPCLIENT-1971:
-------------------------------------------
Summary: Document alternatives to deprecated
AbortableHttpRequest.abort()
Key: HTTPCLIENT-1971
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1971
Project: HttpComponents HttpClient
Issue Type: Wish
Components: Documentation
Affects Versions: 4.5.7
Reporter: Carsten Reckord
The {{AbortableHttpRequest}} interface was deprecated for HttpClient 4.3, but
there is no good documentation on what the alternative is for callers who wish
to cancel a request who would have previously called e.g. HttpGet.abort().
The deprecation notice simply says _"use HttpExecutionAware"_. However, looking
at {{HttpExecutionAware}} and its usages throughout HttpClient, this is
apparenty intended for a different use-case. Or at least it is unclear how
callers would achieve the desired cancellation.
The [examples
page|https://hc.apache.org/httpcomponents-client-ga/examples.html] still lists
the [Abort
method|https://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientAbortMethod.java]
example that uses the deprecated {{HttpGet.abort()}} method.
[Another
example|https://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientWithRequestFuture.java]
that isn't listed on the examples page and hence hard to find shows how to use
{{FutureRequestExecutionService}} to get a cancellable
{{HttpRequestFutureTask}}. But looking at the code, that doesn't actually seem
to cancel the actual request either - it just offloads it to a worker, and if
it isn't already cancelled before the worker runs it, it goes through with the
complete request.
So far, my impression is that the only proper alternative is to go with the
HttpAsyncClient API. But it would be nice if the HttpClient documentation and
the deprecation notice on AbortableHttpRequest would either reflect that, or
give other alternatives more explicitly.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]