jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: svn commit: r1836293 - in /jmeter/trunk: src/components/org/apache/jmeter/config/RandomVariableConfig.java xdocs/changes.xml xdocs/usermanual/component_reference.xml
Date Thu, 19 Jul 2018 19:33:05 GMT
One minor point almost at the end.


Am 19.07.2018 um 21:17 schrieb pmouawad@apache.org:
> Author: pmouawad
> Date: Thu Jul 19 19:17:36 2018
> New Revision: 1836293
>
> URL: http://svn.apache.org/viewvc?rev=1836293&view=rev
> Log:
> Bug 62553 - Random element might return same value even if property "Per thread user
(User)" is set to TRUE
> Bugzilla Id: 62553
>
> Modified:
>      jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
>      jmeter/trunk/xdocs/changes.xml
>      jmeter/trunk/xdocs/usermanual/component_reference.xml
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java?rev=1836293&r1=1836292&r2=1836293&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/config/RandomVariableConfig.java Thu
Jul 19 19:17:36 2018
> @@ -72,7 +72,7 @@ public class RandomVariableConfig extend
>                   @Override
>                   protected Random initialValue() {
>                       init();
> -                    return new Random(getRandomSeedAsLong());
> +                    return createRandom();
>                   }};
>       }
>   
> @@ -113,7 +113,7 @@ public class RandomVariableConfig extend
>               synchronized(this){
>                   if (globalRandom == null){
>                       init();
> -                    globalRandom = new Random(getRandomSeedAsLong());
> +                    globalRandom = createRandom();
>                   }
>                   randGen=globalRandom;
>               }
> @@ -189,20 +189,27 @@ public class RandomVariableConfig extend
>       public synchronized String getRandomSeed() {
>           return randomSeed;
>       }
> +
> +    private Random createRandom() {
> +        if (randomSeed.length()>0){
> +            Long seed = getRandomSeedAsLong();
> +            if(seed != null) {
> +                return new Random(seed.longValue());
> +            }
> +        }
> +        return new Random();
> +    }
>   
>       /**
>        * @return the randomSeed as a long
>        */
> -    private synchronized long getRandomSeedAsLong() {
> -        long seed;
> -        if (randomSeed.length()==0){
> -            seed = System.currentTimeMillis();
> -        }  else {
> -            try {
> -                seed = Long.parseLong(randomSeed);
> -            } catch (NumberFormatException e) {
> -                seed = System.currentTimeMillis();
> -                log.warn("Cannot parse random seed: '{}'", randomSeed);
> +    private synchronized Long getRandomSeedAsLong() {
> +        Long seed = null;
> +        try {
> +            seed = Long.parseLong(randomSeed);
> +        } catch (NumberFormatException e) {
> +            if(log.isWarnEnabled()) {
> +                log.warn("Cannot parse random seed: '{}' in element {}", randomSeed,
getName());
>               }
>           }
>           return seed;
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1836293&r1=1836292&r2=1836293&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
> +++ jmeter/trunk/xdocs/changes.xml [utf-8] Thu Jul 19 19:17:36 2018
> @@ -227,6 +227,7 @@ this behaviour, set <code>httpclient.res
>       <li><bug>61664</bug>HTTP Authorization Manager : Digest works
only with legacy <rfc link="2069" />, <rfc link="2617" /> is not implemented.
Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
>       <li><bug>62252</bug>HTTP header merging logic does not correspond
to the documentation</li>
>       <li><bug>62554</bug>BoundaryExtractor : Field to check is not
reset</li>
> +    <li><bug>62553</bug>Random element might return same value even
if property "Per thread user (User)" is set to TRUE</li>
>   </ul>
>   
>   <h3>Functions</h3>
>
> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1836293&r1=1836292&r2=1836293&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Jul 19 19:17:36 2018
> @@ -4216,9 +4216,10 @@ to use a variable other than a property
>     If not specified, the default is to generate the number using <code>Long.toString()</code></property>
>     <property name="Minimum Value" required="Yes">The minimum value (<code>long</code>)
of the generated random number.</property>
>     <property name="Maximum Value" required="Yes">The maximum value (<code>long</code>)
of the generated random number.</property>
> -  <property name="Random Seed" required="No">The seed for the random number generator.
Default is the current time in milliseconds.
> +  <property name="Random Seed" required="No">The seed for the random number generator.
>     If you use the same seed value with Per Thread set to <code>true</code>,
you will get the same value for each Thread as per
>     <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Random.html" >Random</a>
class.
> +  If no see is set, Default constructor of Random will be used.

Seems like a 'd' is missing :)

Felix
>     </property>
>     <property name="Per Thread(User)?" required="Yes">If <code>False</code>,
the generator is shared between all threads in the thread group.
>     If <code>True</code>, then each thread has its own random generator.</property>
>
>


Mime
View raw message