From 83a36503b2b0b7ea03965480ea85b739e4a79b34 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sun, 1 Aug 2010 16:38:27 +0000 Subject: [PATCH] SOLR-2019: force Jetty to use insecure randomness source when running tests git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@981265 13f79535-47bb-0310-9956-ffa450edef68 --- solr/build.xml | 1 + solr/contrib/dataimporthandler/build.xml | 2 ++ solr/contrib/extraction/build.xml | 1 + .../apache/solr/client/solrj/embedded/JettyWebappTest.java | 4 ++++ .../apache/solr/client/solrj/embedded/JettySolrRunner.java | 5 +++++ 5 files changed, 13 insertions(+) diff --git a/solr/build.xml b/solr/build.xml index d2db702b8bd..ab85b3cc916 100644 --- a/solr/build.xml +++ b/solr/build.xml @@ -436,6 +436,7 @@ + diff --git a/solr/contrib/dataimporthandler/build.xml b/solr/contrib/dataimporthandler/build.xml index 6f29c3dd752..fa5ca20e047 100644 --- a/solr/contrib/dataimporthandler/build.xml +++ b/solr/contrib/dataimporthandler/build.xml @@ -151,6 +151,7 @@ dir="src/test/resources/" tempdir="${junit.output.dir}" > + @@ -191,6 +192,7 @@ failureProperty="tests.failed" dir="src/extras/test/resources/" > + diff --git a/solr/contrib/extraction/build.xml b/solr/contrib/extraction/build.xml index bd7113f2382..11e4aca89a7 100644 --- a/solr/contrib/extraction/build.xml +++ b/solr/contrib/extraction/build.xml @@ -99,6 +99,7 @@ dir="src/test/resources/" tempdir="${junit.output.dir}" > + diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java index 7090c470663..23a2dc85b01 100644 --- a/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java +++ b/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java @@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.embedded; import java.io.File; import java.net.URL; +import java.util.Random; import junit.framework.TestCase; @@ -26,6 +27,7 @@ import org.apache.commons.io.IOUtils; import org.mortbay.jetty.Connector; import org.mortbay.jetty.Server; import org.mortbay.jetty.bio.SocketConnector; +import org.mortbay.jetty.servlet.HashSessionIdManager; import org.mortbay.jetty.webapp.WebAppContext; /** @@ -52,6 +54,8 @@ public class JettyWebappTest extends TestCase String path = "../../webapp/web"; server = new Server(port); + // insecure: only use for tests!!!! + server.setSessionIdManager(new HashSessionIdManager(new Random())); new WebAppContext(server, path, context ); SocketConnector connector = new SocketConnector(); diff --git a/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java b/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java index 2bb2f5ab38f..146d4c151aa 100644 --- a/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java +++ b/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java @@ -20,6 +20,7 @@ package org.apache.solr.client.solrj.embedded; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.util.Random; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -31,6 +32,7 @@ import org.mortbay.jetty.Server; import org.mortbay.jetty.Connector; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.FilterHolder; +import org.mortbay.jetty.servlet.HashSessionIdManager; import org.mortbay.log.Logger; /** @@ -75,6 +77,9 @@ public class JettySolrRunner { this.context = context; server = new Server( port ); + if (System.getProperty("jetty.insecurerandom") != null) + server.setSessionIdManager(new HashSessionIdManager(new Random())); + server.setStopAtShutdown( true ); // Initialize the servlets