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

Global vs local source of randomness

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0

    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

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

              Dates

                Created:
                Updated:
                Resolved: