You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "cda (Jira)" <ji...@apache.org> on 2021/04/24 15:02:00 UTC
[jira] [Resolved] (HTTPCLIENT-2154) Cannot extend
CloseableHttpClient
[ https://issues.apache.org/jira/browse/HTTPCLIENT-2154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
cda resolved HTTPCLIENT-2154.
-----------------------------
Resolution: Won't Fix
Use public `execute` method instead of `protected` one.
Ideally, `HttpClientBuilder.build()` should return an interface that doesn't have this issue.
> Cannot extend CloseableHttpClient
> ---------------------------------
>
> Key: HTTPCLIENT-2154
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2154
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient (classic)
> Affects Versions: 5.1-beta1
> Reporter: cda
> Priority: Major
>
> Trying to extend a CloseableHttpClient to add custom features.
> This is not possible because of the [protected doExecute|https://github.com/apache/httpcomponents-client/blob/656d0dd4f3b5ceefc649cb2bd0d952db65dd014c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/CloseableHttpClient.java#L59-L60] method, example:
> {code:java}
> class CustomCloseableHttpClient extends CloseableHttpClient {
> private CloseableHttpClient httpClient;
> public CustomCloseableHttpClient( CloseableHttpClient httpClient ) {
> this.httpClient = httpClient;
> }
> @Override
> protected CloseableHttpResponse doExecute( HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext ) throws IOException, ClientProtocolException {
> return httpClient.doExecute( httpHost, httpRequest, httpContext ); //error, cannot call protected method
> }
> {code}
> This protected method has the same signature as another public method that only forwards calls.
> The protected method doesn't add any logic, so it can be removed and use the public one instead, thus allowing extension.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org