Uploaded image for project: 'Commons Text'
  1. Commons Text
  2. TEXT-37

Global vs local source of randomness

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Labels:

      Description

      This is a follow-up of a discussion held in TEXT-34.

      By default, RandomStringBuilder will use a shared java.util.Random object.

      I think that the decision of which generator to use lies with the code that constructs the RandomStringBuilder instance, not with code that uses it (to build a string).
      It would be safer to pass the RNG instance at construction (since, anyways, the constructor must be called):

      RandomStringBuilder sb = new RandomStringBuilder(new MyRandom());
      String s = sb.ofLength(length).build();
      

      In the above, the MyRandom type is the subject of TEXT-36.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dmjones500 Duncan Jones
                Reporter:
                erans Gilles
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: