You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chesnay Schepler (JIRA)" <ji...@apache.org> on 2018/09/03 08:49:00 UTC

[jira] [Closed] (FLINK-10186) Use ThreadLocalRandom in BufferSpiller constructor

     [ https://issues.apache.org/jira/browse/FLINK-10186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chesnay Schepler closed FLINK-10186.
------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.7.0

master: d216dc9803750050e8c9d369ad468c5125119407

> Use ThreadLocalRandom in BufferSpiller constructor
> --------------------------------------------------
>
>                 Key: FLINK-10186
>                 URL: https://issues.apache.org/jira/browse/FLINK-10186
>             Project: Flink
>          Issue Type: Improvement
>          Components: Streaming
>    Affects Versions: 1.7.0
>            Reporter: Hiroaki Yoshida
>            Assignee: Hiroaki Yoshida
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.7.0
>
>
> FindBugs-3.0.1 ([http://findbugs.sourceforge.net/]) reported a DMI_RANDOM_USED_ONLY_ONCE warning on master:
> {code:java}
> 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]
> {code}
> The description of the bug is as follows:
> {quote}*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]
> {quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)