Add deterministic random class - #1255
Open
210-reverof wants to merge 3 commits into
Open
Conversation
github-actions
Bot
requested review from
SooKim1110,
acktsap,
benelog,
jwChung,
mhyeon-lee and
seongahjo
November 10, 2025 14:59
seongahjo
reviewed
Nov 11, 2025
seongahjo
reviewed
Nov 11, 2025
seongahjo
reviewed
Nov 11, 2025
| import org.apiguardian.api.API.Status; | ||
|
|
||
| @API(since = "1.1.16", status = Status.MAINTAINED) | ||
| public class DeterministicRandom extends Random { |
Contributor
There was a problem hiding this comment.
I think it would be better to create a new interface for obtaining the Random instance and the seed value.
It is to avoid using the DeterministicRandom directly.
Contributor
Author
There was a problem hiding this comment.
Thank you for your feedback! 🙂
I created a new interface named RandomSource to obtain Random instances and seed values.
I also implemented DeterministicRandomSource that encapsulates the caching logic,
so the internal implementation is no longer exposed.
Contributor
There was a problem hiding this comment.
@210-reverof
I think DeterministicRandom is also needed.
It will be an implementation of RandomSource
210-reverof
force-pushed
the
add-deterministic-random-class
branch
from
December 14, 2025 08:28
7077b4a to
237fa16
Compare
210-reverof
force-pushed
the
add-deterministic-random-class
branch
from
December 14, 2025 08:33
38a7176 to
84e0308
Compare
seongahjo
force-pushed
the
main
branch
2 times, most recently
from
March 5, 2026 08:44
26fed51 to
5476662
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implement DeterministicRandom class with seed-based Random instance caching for deterministic test reproducibility.
Description
DeterministicRandomclass that extendsRandomnextLong()generated values as keysgetRandomInstance(long seed)to retrieve cached Random instances by seedgetCurrentSeedRandom()to get the Random instance for the current seedHow Has This Been Tested?
./gradlew :fixture-monkey-api:testpasses successfullynextLong(), instance retrieval, cache size limit (≤32), deterministic behavior, and seed independenceIs the Document updated?
Not yet.