[ 
https://issues.apache.org/jira/browse/LANG-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15576851#comment-15576851
 ] 

Bruno P. Kinoshita commented on LANG-1196:
------------------------------------------

Thanks for providing a patch so quickly.

{code}
    public static void seed(long seed) {
        RANDOM = new Random(seed);
    }
{code}

This could cause race conditions, where one thread could call a method to 
generate a random, while another user modifies the same instance of Random.

I suggested returning a new instance, kind like a Builder object, but all the 
methods are static, and it would be at least weird to create an instance to 
call the static methods, that also access at least one static member. That 
could create new problems. I think we would either have to rewrite with a 
different design, or keep it as static methods, but perhaps adding a few more 
that receive a Random object? WDYT?

Cannot really review the new Scenario object without more time to read and 
understand the other changes, but maybe someone else could chime in and take a 
look on it.

Thanks again!
Bruno

> Provide way to set random number generator on RandomStringUtils to enable 
> repeatable test execution
> ---------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1196
>                 URL: https://issues.apache.org/jira/browse/LANG-1196
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.4
>         Environment: java version "1.8.0_66"
> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
> Linux 4.0.5 #3 SMP Mon Sep 14 12:41:09 BST 2015 x86_64 Intel(R) Core(TM) 
> i7-4710MQ CPU @ 2.50GHz GenuineIntel GNU/Linux
>            Reporter: Gus Power
>            Priority: Minor
>         Attachments: LANG-1196.patch
>
>
> Hi,
> I'm using [Sham 
> |http://search.maven.org/#artifactdetails%7Corg.shamdata%7Csham%7C0.3%7Cjar] 
> to generate realistic looking test data for both parameterized tests and user 
> acceptance testing. We log the seed that is used for each run so that if 
> there is an issue we can recreate exactly the same test data. I would also 
> like to use some of the commons-lang RandomStringUtils functionality but 
> notice that the implementation provides no way of setting the random number 
> generator to be used.
> {code}private static final Random RANDOM = new Random();{code}
> A way to configure this would be really useful. If there is an alternative 
> way to do this then that would be great. If you think it's a good idea and it 
> requires a patch I'm happy to supply one.
> Cheers,
> Gus.
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to