You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/07/03 18:28:28 UTC

[GitHub] [httpcomponents-client] slisaasquatch opened a new pull request #233: Optimize MultipartEntityBuilder#generateBoundary

slisaasquatch opened a new pull request #233:
URL: https://github.com/apache/httpcomponents-client/pull/233


   I've changed generateBoundary to use `ThreadLocalRandom` instead of creating a new `Random` every time, and I've replaced the `StringBuilder` with the faster `CharBuffer`.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [httpcomponents-client] slisaasquatch commented on pull request #233: Optimize MultipartEntityBuilder#generateBoundary

Posted by GitBox <gi...@apache.org>.
slisaasquatch commented on pull request #233:
URL: https://github.com/apache/httpcomponents-client/pull/233#issuecomment-653648418


   @michael-o No, I don't have any numbers. I just thought it was an easy improvement to make.
   @ok2c `ThreadLocalRandom` is not really a regular `ThreadLocal` that's used to store a temporary state. The purpose of `ThreadLocalRandom` is to avoid synchronization. Basically all the `new Random()` calls can be safely replaced with `ThreadLocalRandom.current()` without negative side effects. [Here's the official documentation](https://docs.oracle.com/javase/tutorial/essential/concurrency/threadlocalrandom.html).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [httpcomponents-client] ok2c commented on pull request #233: Optimize MultipartEntityBuilder#generateBoundary

Posted by GitBox <gi...@apache.org>.
ok2c commented on pull request #233:
URL: https://github.com/apache/httpcomponents-client/pull/233#issuecomment-653647045


   @michael-o `ThreadLocal`s must be used with _extreme_ caution and generally should have a very specific, short life span, like duration of an HTTP request / response exchange in a Servlet environment. I need to take a very close look at `ThreadLocalRandom` before I can make up my mind. The rest looks just fine.
     


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [httpcomponents-client] ok2c merged pull request #233: Optimize MultipartEntityBuilder#generateBoundary

Posted by GitBox <gi...@apache.org>.
ok2c merged pull request #233:
URL: https://github.com/apache/httpcomponents-client/pull/233


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [httpcomponents-client] ok2c commented on pull request #233: Optimize MultipartEntityBuilder#generateBoundary

Posted by GitBox <gi...@apache.org>.
ok2c commented on pull request #233:
URL: https://github.com/apache/httpcomponents-client/pull/233#issuecomment-653735195


   @slisaasquatch Fair enough. Merged.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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