cda created HTTPCLIENT-2154:
-------------------------------

             Summary: 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


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-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to