[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16747208#comment-16747208
 ] 

Yuyang Wang commented on HTTPCLIENT-1963:
-----------------------------------------

[~olegk] Thank you for your response. I guess I should give more context. Our 
system calls HttpClientBuilder.build() to create new CloseableHttpClient for 
downstream service call. This construction happens every time we want to 
trigger a new service call. The HttpClientBuilder.build() method actually 
creates many nested objects, not only MainClientExec, and all of them retrieves 
Log at creation instead of making them static. This seems a pattern in the 
HttpClient library. Some examples:

 
{code:java}
HttpClientBuilder.build() ->
HttpClientBuilder.createMainExec() ->
new MainClientExec() ->
LogFactory.getLog()
HttpClientBuilder.build() ->
new ProtocolExec() ->
LogFactory.getLog()
HttpClientBuilder.build() ->
new InternalHttpClient() ->
LogFactory.getLog()
HttpClientBuilder.build() ->
new InternalHttpClient() ->
new CloseableHttpClient() ->
LogFactory.getLog()
{code}
 

Maybe I missed something, but seems Log is tied to the target class type, thus 
the same one should be returned at every LogFactory.getLog() as long as the 
class parameter is the same. If so, is the Log retrieval at construction 
pattern there because of thread-safety or some other reason? Or there is some 
other recommended way of using HttpClientBuilder.build(), e.g. a client pool?

> Making Log Object in MainClientExec Static
> ------------------------------------------
>
>                 Key: HTTPCLIENT-1963
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1963
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>            Reporter: Yuyang Wang
>            Priority: Major
>
> In MainClientExec constructor, the Log object is retrieved from LogFactory. 
> For clients which construct a lot of MainClientExec instances, it may improve 
> the performance by making the log reference static.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to