Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-10186

Use ThreadLocalRandom in BufferSpiller constructor

    XMLWordPrintableJSON

Details

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

    Description

      FindBugs-3.0.1 (http://findbugs.sourceforge.net/) reported a DMI_RANDOM_USED_ONLY_ONCE warning on master:

      H B DMI: Random object created and used only once in new org.apache.flink.streaming.runtime.io.BufferSpiller(IOManager, int)  At BufferSpiller.java:[line 118]
      

      The description of the bug is as follows:

      DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE)
      This code creates a java.util.Random object, uses it to generate one random number, and then discards the Random object. This produces mediocre quality random numbers and is inefficient. If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number is required invoke a method on the existing Random object to obtain it.

      If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead (and avoid allocating a new SecureRandom for each random number needed).
      http://findbugs.sourceforge.net/bugDescriptions.html#DMI_RANDOM_USED_ONLY_ONCE

      Attachments

        Issue Links

          Activity

            People

              hiroakiyoshida Hiroaki Yoshida
              hiroakiyoshida Hiroaki Yoshida
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: