You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
Bug: Input Validation Flaws in Random Number Methods
The nextInt(int n) method is missing validation for n <= 0, which can cause an ArithmeticException (for n=0) or lead to unpredictable behavior and potential infinite loops (for n < 0). Similarly, nextLong(long n) only validates n == 0; negative n values can also cause unpredictable behavior or infinite loops. A stray semicolon at line 183 serves no purpose.
The reason will be displayed to describe this comment to others. Learn more.
Bug: Random Class Regression Causes Thread Safety Issues
The Random class introduced a thread safety regression. It switched from AtomicLong and synchronized methods to unsynchronized plain long fields (state, inc). This creates race conditions, which can corrupt the internal state and degrade random number quality in concurrent use. The setSeed method, previously synchronized, now also lacks protection, as indicated by a TODO.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Replace GPL licensed Random with MIT licensed PCG random
Here's benchmark results for generating UUIDs with different versions of Random:
This shows the new PCG based
Randomis similar in single threaded performance tojava.util.Randomwhich the old implementation was a subset of.💡 Motivation and Context
Avoid GPL licensed code in SDK
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps