Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1341

"RandomDataGenerator" is brittle

    XMLWordPrintableJSON

Details

    Description

      Class RandomDataGenerator can easily be misused as it advertizes a method to access its internal RNG (which is not thread-safe).

      The class is also a mixed bag of "data generators" that are either "secure" or not.
      Moreover it uses the "lazy initialization" pattern (for the RNG instance) solely because of this duality; otherwise users that need one or the other form of data generation will obviously always use the RNG since all data generation methods need it.
      This entails also a performance hit (albeit tiny) as each call checks whether the RNG has been initialized already.
      The clean solution would be to separate the two types of data generation (secure vs not) into different classes.

      Attachments

        1. RandomUtils.java
          19 kB
          Gilles Sadowski

        Issue Links

          Activity

            People

              Unassigned Unassigned
              erans Gilles Sadowski
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: