SOLR-7493: Initialize random correctly

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-06-06 20:11:20 +00:00
parent e1ca83240e
commit c49d7b654e
1 changed files with 8 additions and 2 deletions

View File

@ -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;