You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Yuyang Wang (JIRA)" <ji...@apache.org> on 2019/01/19 17:17:00 UTC

[jira] [Comment Edited] (HTTPCLIENT-1963) Making Log Object in MainClientExec Static

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

Yuyang Wang edited comment on HTTPCLIENT-1963 at 1/19/19 5:16 PM:
------------------------------------------------------------------

[~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?


was (Author: yuyangw):
[~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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org