jira-importer opened a new issue, #1486: URL: https://github.com/apache/httpcomponents-core/issues/1486
**[Pierre N.](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=pierz)** opened **[HTTPCORE-731](https://issues.apache.org/jira/browse/HTTPCORE-731?redirect=false)** and commented 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 ```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; ``` --- **Affects:** 5.2 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
