Pierre N. created HTTPCORE-731:
----------------------------------
Summary: Don't deprecated HttpClient.execute
Key: HTTPCORE-731
URL: https://issues.apache.org/jira/browse/HTTPCORE-731
Project: HttpComponents HttpCore
Issue Type: Improvement
Affects Versions: 5.2
Reporter: Pierre N.
I just upgraded from 5.1 to 5.2 and just saw that the HttpClient.execute has
been deprecated in favor of a ResponseHandler passed by parameter.
While I understand you point of view and the potential risk of non closed
resource, I wanted to let you know it is not very pleasant to work with
callback based API.
It create non straight forward code, we have to use and create a lot of
exception and the code is less readable and maintenable (very similar to
javascript callback hell).
I really prefer the previous way which should be used with a try-with-resource
block to avoid leak.
Imagine if every closeable resource would have to be open with callback ?
Socket, File, Malloc ! etc. It would be very painful.
Please could you leave some responsibility to your API users ? Most of us know
how to close a resource handle :D
{code:java}
/*
* @deprecated It is strongly recommended to use execute methods with {@link
HttpClientResponseHandler}
* such as {@link #execute(ClassicHttpRequest, HttpClientResponseHandler)} in
order
* to ensure automatic resource deallocation by the client.
* For special cases one can still use {@link #executeOpen(HttpHost,
ClassicHttpRequest, HttpContext)}
* to keep the response object open after the request execution.
*
* @see #execute(ClassicHttpRequest, HttpClientResponseHandler)
* @see #executeOpen(HttpHost, ClassicHttpRequest, HttpContext)
*/
@Deprecated
HttpResponse execute(ClassicHttpRequest request) throws IOException; {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]