You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "Alonexc (via GitHub)" <gi...@apache.org> on 2023/03/17 01:40:11 UTC

[GitHub] [incubator-eventmesh] Alonexc opened a new issue, #3466: [Enhancement] Save and re-use this "Random"

Alonexc opened a new issue, #3466:
URL: https://github.com/apache/incubator-eventmesh/issues/3466

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Enhancement Request
   
   ![image](https://user-images.githubusercontent.com/91315508/225789463-72d51125-c71b-45da-9aea-2e91d2c7522d.png)
   located at:
   eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java line 63
   analysis and explanation:
   Creating a new Random object each time a random value is needed is inefficient and may produce numbers which are not random depending on the JDK. For better efficiency and randomness, create a single Random, then store, and reuse it.
   The Random() constructor tries to set the seed with a distinct value every time. However there is no guarantee that the seed will be random or even uniformly distributed. Some JDK will use the current time as seed, which makes the generated numbers not random at all.
   This rule finds cases where a new Random is created each time a method is invoked.
   
   
   ### Describe the solution you'd like
   
   ![image](https://user-images.githubusercontent.com/91315508/225789505-c6f2ffbc-2f4b-43ca-98ce-16e76ca3f103.png)
   
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


[GitHub] [eventmesh] xwm1992 closed issue #3466: [Enhancement] Save and re-use this "Random"

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 closed issue #3466: [Enhancement] Save and re-use this "Random"
URL: https://github.com/apache/eventmesh/issues/3466


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org