Winfried Gerlach created HTTPCLIENT-2385:
--------------------------------------------

             Summary: Make Default...ClientConnection extensible
                 Key: HTTPCLIENT-2385
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2385
             Project: HttpComponents HttpClient
          Issue Type: Improvement
            Reporter: Winfried Gerlach


I'd like to improve extensibility of {{DefaultManagedHttpClientConnection}} and 
{{{}DefaultManagedAsyncClientConnection{}}}. My request somehow resembles the 
very old issue HTTPCLIENT-1374, in which {{DefaultManagedHttpClientConnection}} 
was made public.

IMHO, implementations named {{Default...}} should both demonstrate best 
practices of API usage and act as easily modifiable blueprints for HttpClient 
users. This is currently not the case, because both 
{{DefaultManagedHttpClientConnection}} and 
{{DefaultManagedAsyncClientConnection}} are final and 
{{DefaultManagedHttpClientConnection}} uses package-private classes 
({{{}Logging...*{}}}).

So if you want to write your own, slightly modified 
{{MyManagedHttpClientConnection}} (e.g., change some logging or call a callback 
when a method is invoked), you will need to extend the super class 
{{DefaultBHttpClientConnection}} (which is public non-final), copy a lot of 
code from {{DefaultManagedHttpClientConnection}} and possibly even create your 
own copies of {{{}LoggingInputStream{}}}, {{{}LoggingOutputStream{}}}, and 
{{{}LoggingSocketHolder{}}}. Something that could be done with very few lines 
of code, maybe even in an anonymous class, has then become multiple classes 
with several hundred LoC to review and maintain (especially if 
{{DefaultBHttpClientConnection}} or {{DefaultManagedHttpClientConnection}} are 
changed in future versions of HttpClient).

I suggest to
 * make {{DefaultManagedHttpClientConnection}} and 
{{DefaultManagedAsyncClientConnection}} public non-final
 * make {{{}LoggingInputStream{}}}, {{{}LoggingOutputStream{}}}, and 
{{LoggingSocketHolder}} public

This shouldn't hurt anyone (doesn't break APIs) and help some users like our 
project.

I'll provide a PR via GitHub.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to