From c49d7b654e34c8c3309a14eb85b9bb7be054e139 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Sat, 6 Jun 2015 20:11:20 +0000 Subject: [PATCH] SOLR-7493: Initialize random correctly git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683948 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/solr/servlet/HttpSolrCall.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java index e374d8e5bad..35f89dd2ddc 100644 --- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java +++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java @@ -117,10 +117,16 @@ import org.slf4j.LoggerFactory; public class HttpSolrCall { protected static Logger log = LoggerFactory.getLogger(HttpSolrCall.class); - protected static Random random; + static final Random random; static { + // We try to make things reproducible in the context of our tests by initializing the random instance + // based on the current seed String seed = System.getProperty("tests.seed"); - random = new Random(seed != null ? Long.parseLong(seed) : System.currentTimeMillis()); + if (seed == null) { + random = new Random(); + } else { + random = new Random(seed.hashCode()); + } } protected final SolrDispatchFilter solrDispatchFilter;