Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-4189: Fix hanging threads on FreeBSD in JettySolrRunner by making connector configureable through sysprop, listen only on 127.0.0.1 in tests

Uwe Schindler6af24c886668
diff --git a/build.xml b/build.xml
index 507acf980f7..39928aea0cb 100644
--- a/build.xml
+++ b/build.xml
@@ -154,6 +154,7 @@
<subant buildpath="." antfile="extra-targets.xml" target="-run-maven-build" inheritall="false" failonerror="true">
<propertyset>
<propertyref prefix="maven-"/>
+ <propertyref builtin="commandline"/>
</propertyset>
</subant>
</target>
diff --git a/dev-tools/maven/solr/pom.xml.template b/dev-tools/maven/solr/pom.xml.template
index 6c546006a70..7feaa2ddfd2 100644
--- a/dev-tools/maven/solr/pom.xml.template
+++ b/dev-tools/maven/solr/pom.xml.template
@@ -99,6 +99,15 @@
<doctitle>${project.name} ${project.version} API (${now.version})</doctitle>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <tests.jettyConnector>${tests.jettyConnector}</tests.jettyConnector>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
</build>
diff --git a/extra-targets.xml b/extra-targets.xml
index a073454a00f..6696de0bf67 100644
--- a/extra-targets.xml
+++ b/extra-targets.xml
@@ -56,6 +56,9 @@
mavenVersion="${maven-version}" failonerror="true" fork="true">
<arg value="-fae"/>
<arg value="install"/>
+ <syspropertyset>
+ <propertyref builtin="commandline"/>
+ </syspropertyset>
</mvn>
</target>
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 42226b35d0a..2df073a9f3c 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -916,6 +916,7 @@
<propertyref prefix="tests.failfast" />
<propertyref prefix="tests.badapples" />
<propertyref prefix="tests.timeoutSuite" />
+ <propertyref prefix="tests.jettyConnector" />
</syspropertyset>
<!-- Pass randomized settings to the forked JVM. -->
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
index a4f5281087c..56e995db00b 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
@@ -154,12 +154,25 @@ public class JettySolrRunner {
}
System.setProperty("solr.solr.home", solrHome);
if (System.getProperty("jetty.testMode") != null) {
- SelectChannelConnector connector = new SelectChannelConnector();
+ final String connectorName = System.getProperty("tests.jettyConnector", "SelectChannel");
+ final Connector connector;
+ final QueuedThreadPool threadPool;
+ if ("SelectChannel".equals(connectorName)) {
+ final SelectChannelConnector c = new SelectChannelConnector();
+ c.setReuseAddress(true);
+ c.setLowResourcesMaxIdleTime(1500);
+ connector = c;
+ threadPool = (QueuedThreadPool) c.getThreadPool();
+ } else if ("Socket".equals(connectorName)) {
+ final SocketConnector c = new SocketConnector();
+ c.setReuseAddress(true);
+ connector = c;
+ threadPool = (QueuedThreadPool) c.getThreadPool();
+ } else {
+ throw new IllegalArgumentException("Illegal value for system property 'tests.jettyConnector': " + connectorName);
+ }
connector.setPort(port);
- connector.setReuseAddress(true);
- connector.setLowResourcesMaxIdleTime(1500);
- QueuedThreadPool threadPool = (QueuedThreadPool) connector
- .getThreadPool();
+ connector.setHost("127.0.0.1");
if (threadPool != null) {
threadPool.setMaxThreads(10000);
threadPool.setMaxIdleTimeMs(5000);