sonatype-lift[bot] commented on a change in pull request #255:
URL: https://github.com/apache/solr/pull/255#discussion_r689803753
##########
File path: solr/benchmark/src/java/org/apache/solr/bench/BaseBenchState.java
##########
@@ -0,0 +1,57 @@
+package org.apache.solr.bench;
+
+import org.apache.solr.common.util.SuppressForbidden;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.BenchmarkParams;
+
+import java.util.Random;
+import java.util.SplittableRandom;
+
+@State(Scope.Benchmark)
+public class BaseBenchState {
+
+ private static final long RANDOM_SEED = 6624420638116043983L;
+
+ private SplittableRandom random;
+
+ public static boolean quietLog = Boolean.getBoolean("quietLog");
+
+ @SuppressForbidden(reason = "JMH uses std out for user output")
+ public static void log(String value) {
+ if (!quietLog) {
+ System.out.println((value.equals("") ? "" : "--> ") + value);
+ }
+ }
+
+ @Setup(Level.Trial)
+ public void doSetup(BenchmarkParams benchmarkParams) throws Exception {
+ System.setProperty("solr.log.name", benchmarkParams.id());
+
+ Long seed = getRandomSeed();
+
+ this.random = new SplittableRandom(seed);
+ }
+
+
+ public static Long getRandomSeed() {
+ Long seed = Long.getLong("solr.bench.seed");
+
+ if (seed == null) {
+ seed = RANDOM_SEED;
+ }
+
+ log("benchmark random seed: " + seed);
+
+ // set the seed used by hard to reach places
+ System.setProperty("randomSeed", Long.toString(new
Random(seed).nextLong()));
Review comment:
*PREDICTABLE_RANDOM:* This random generator (java.util.Random) is
predictable
[(details)](https://find-sec-bugs.github.io/bugs.htm#PREDICTABLE_RANDOM)
(at-me [in a reply](https://help.sonatype.com/lift) with `help` or `ignore`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]