You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2012/08/13 10:18:13 UTC

svn commit: r1372307 - in /lucene/dev/branches/branch_4x: dev-tools/eclipse/ dev-tools/idea/.idea/libraries/ dev-tools/maven/ lucene/ lucene/core/src/test/org/apache/lucene/ lucene/core/src/test/org/apache/lucene/index/ lucene/core/src/test/org/apache/...

Author: dweiss
Date: Mon Aug 13 08:18:11 2012
New Revision: 1372307

URL: http://svn.apache.org/viewvc?rev=1372307&view=rev
Log:
LUCENE-3985: Upgrade to randomizedtesting 2.0.0. Added support for thread leak detection. Added support for suite timeouts.

Added:
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/TestWorstCaseTestBehavior.java
    lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-2.0.0.rc5.jar.sha1
    lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-2.0.0.rc5.jar.sha1
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/QuickPatchThreadsFilter.java
      - copied, changed from r1372246, lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java
    lucene/dev/branches/branch_4x/lucene/tools/forbiddenApis/executors.txt
    lucene/dev/branches/branch_4x/lucene/tools/junit4/logging.properties
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/SolrjNamedThreadFactory.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RevertDefaultThreadHandlerRule.java
Removed:
    lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-1.6.0.jar.sha1
    lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-1.6.0.jar.sha1
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleNoInstanceHooksOverrides.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleNoStaticHooksShadowing.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleReportUncaughtExceptions.java
Modified:
    lucene/dev/branches/branch_4x/dev-tools/eclipse/dot.classpath
    lucene/dev/branches/branch_4x/dev-tools/idea/.idea/libraries/JUnit.xml
    lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt
    lucene/dev/branches/branch_4x/lucene/build.xml
    lucene/dev/branches/branch_4x/lucene/common-build.xml
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
    lucene/dev/branches/branch_4x/lucene/ivy-settings.xml
    lucene/dev/branches/branch_4x/lucene/module-build.xml
    lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
    lucene/dev/branches/branch_4x/lucene/test-framework/ivy.xml
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneJUnit3MethodProvider.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java
    lucene/dev/branches/branch_4x/lucene/tools/custom-tasks.xml
    lucene/dev/branches/branch_4x/solr/build.xml
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/CommitTracker.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java

Modified: lucene/dev/branches/branch_4x/dev-tools/eclipse/dot.classpath
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/eclipse/dot.classpath?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/eclipse/dot.classpath (original)
+++ lucene/dev/branches/branch_4x/dev-tools/eclipse/dot.classpath Mon Aug 13 08:18:11 2012
@@ -174,6 +174,6 @@
   <classpathentry kind="lib" path="solr/contrib/velocity/lib/commons-beanutils-1.7.0.jar"/>
   <classpathentry kind="lib" path="solr/contrib/velocity/lib/commons-collections-3.2.1.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="lucene/test-framework/lib/randomizedtesting-runner-1.6.0.jar"/>
+	<classpathentry kind="lib" path="lucene/test-framework/lib/randomizedtesting-runner-2.0.0.rc5.jar"/>
 	<classpathentry kind="output" path="bin/other"/>
 </classpath>

Modified: lucene/dev/branches/branch_4x/dev-tools/idea/.idea/libraries/JUnit.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/idea/.idea/libraries/JUnit.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/idea/.idea/libraries/JUnit.xml (original)
+++ lucene/dev/branches/branch_4x/dev-tools/idea/.idea/libraries/JUnit.xml Mon Aug 13 08:18:11 2012
@@ -2,7 +2,7 @@
   <library name="JUnit">
     <CLASSES>
       <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/junit-4.10.jar!/" />
-      <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-1.6.0.jar!/" />
+      <root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-2.0.0.rc5.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES />

Modified: lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template Mon Aug 13 08:18:11 2012
@@ -385,7 +385,7 @@
       <dependency>
         <groupId>com.carrotsearch.randomizedtesting</groupId>
         <artifactId>randomizedtesting-runner</artifactId>
-        <version>1.6.0</version>
+        <version>2.0.0.rc5</version>
       </dependency>
     </dependencies>
   </dependencyManagement>

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Mon Aug 13 08:18:11 2012
@@ -52,6 +52,11 @@ Bug Fixes
   upgraded to 3.x, then to Lucene 4.0-ALPHA or -BETA, you should run 
   CheckIndex. If it fails, then you need to upgrade again to 4.0  (Robert Muir)
 
+Build
+
+* LUCENE-3985: Upgrade to randomizedtesting 2.0.0. Added support for 
+  thread leak detection. Added support for suite timeouts. (Dawid Weiss)
+
 ======================= Lucene 4.0.0-BETA =======================
 
 New features

Modified: lucene/dev/branches/branch_4x/lucene/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/build.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/build.xml Mon Aug 13 08:18:11 2012
@@ -153,6 +153,7 @@
       <apiFileSet dir="${custom-tasks.dir}/forbiddenApis">
         <include name="jdk.txt" />
         <include name="jdk-deprecated.txt" />
+        <include name="executors.txt" />
       </apiFileSet>
       <fileset dir="${basedir}/build" includes="**/*.class" />
     </forbidden-apis>

Modified: lucene/dev/branches/branch_4x/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/common-build.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/common-build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/common-build.xml Mon Aug 13 08:18:11 2012
@@ -88,7 +88,7 @@
   <property name="tests.timezone" value="random" />
   <property name="tests.directory" value="random" />
   <property name="tests.linedocsfile" value="europarl.lines.txt.gz" />
-  <property name="tests.loggingfile" value="/dev/null"/>
+  <property name="tests.loggingfile" value="${common.dir}/tools/junit4/logging.properties"/>
   <property name="tests.nightly" value="false" />
   <property name="tests.weekly" value="false" />
   <property name="tests.slow" value="true" />
@@ -700,15 +700,22 @@
   <condition property="tests.method" value="${testmethod}*">
     <isset property="testmethod" />
   </condition>
+
   <condition property="tests.showSuccess" value="true">
     <or>
       <isset property="tests.class" />
       <isset property="tests.method" />
     </or>
   </condition>
-  <!-- default -->
   <property name="tests.showSuccess" value="false"/>
-  
+
+  <condition property="tests.showOutput" value="always">
+    <or>
+      <isset property="tests.class" />
+      <isset property="tests.method" />
+    </or>
+  </condition>
+  <property name="tests.showOutput" value="onerror"/>
 
   <!-- Test macro using junit4. -->
   <macrodef name="test-macro" description="Executes junit tests.">
@@ -854,6 +861,7 @@
             <syspropertyset>
                 <propertyref prefix="tests.maxfailures" />
                 <propertyref prefix="tests.failfast" />
+                <propertyref prefix="tests.badapples" />
             </syspropertyset>
 
             <!-- Pass randomized settings to the forked JVM. -->
@@ -875,8 +883,7 @@
                 <junit4:report-text
                     showThrowable="true" 
                     showStackTraces="true" 
-                    showOutputStream="true" 
-                    showErrorStream="true"
+                    showOutput="${tests.showOutput}" 
 
                     showStatusOk="${tests.showSuccess}"
                     showStatusError="${tests.showError}"
@@ -896,8 +903,7 @@
                     file="@{junit.output.dir}/tests-report.txt"
                     showThrowable="true" 
                     showStackTraces="true" 
-                    showOutputStream="true" 
-                    showErrorStream="true"
+                    showOutput="always"
 
                     showStatusOk="true"
                     showStatusError="true"
@@ -913,8 +919,7 @@
                     file="@{junit.output.dir}/tests-failures.txt"
                     showThrowable="true" 
                     showStackTraces="true" 
-                    showOutputStream="true" 
-                    showErrorStream="true"
+                    showOutput="onerror" 
 
                     showStatusOk="false"
                     showStatusError="true"
@@ -929,8 +934,13 @@
                      the slowest tests or for reuse in balancing). -->
                 <junit4:report-execution-times file="@{junit.output.dir}/tests-timehints.txt" historyLength="5" />
 
-                <junit4:report-ant-xml dir="@{junit.output.dir}" />
-                <junit4:report-json file="@{junit.output.dir}/tests-report-${ant.project.name}/index.html" />
+                <!-- ANT-compatible XMLs for jenkins records etc. -->
+                <junit4:report-ant-xml dir="@{junit.output.dir}" outputStreams="no" />
+
+                <!--
+                Enable if you wish to have a nice HTML5 report.
+                <junit4:report-json file="@{junit.output.dir}/tests-report-${ant.project.name}/index.html" outputStreams="no" />
+                -->
             </listeners>
 
             <!-- Input test classes. -->

Added: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/TestWorstCaseTestBehavior.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/TestWorstCaseTestBehavior.java?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/TestWorstCaseTestBehavior.java (added)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/TestWorstCaseTestBehavior.java Mon Aug 13 08:18:11 2012
@@ -0,0 +1,98 @@
+package org.apache.lucene;
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Ignore;
+
+import com.carrotsearch.randomizedtesting.RandomizedTest;
+import com.carrotsearch.randomizedtesting.annotations.Timeout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class TestWorstCaseTestBehavior extends LuceneTestCase {
+  @Ignore
+  public void testThreadLeak() {
+    Thread t = new Thread() {
+      @Override
+      public void run() {
+        try {
+          Thread.sleep(10000);
+        } catch (InterruptedException e) {
+          // Ignore.
+        }
+      }
+    };
+    t.start();
+
+    while (!t.isAlive()) {
+      Thread.yield();
+    }
+
+    // once alive, leave it to run outside of the test scope.
+  }
+
+  @Ignore
+  public void testLaaaaaargeOutput() throws Exception {
+    String message = "I will not OOM on large output";
+    int howMuch = 250 * 1024 * 1024;
+    for (int i = 0; i < howMuch; i++) {
+      if (i > 0) System.out.print(",\n");
+      System.out.print(message);
+      howMuch -= message.length(); // approximately.
+    }
+    System.out.println(".");
+  }
+
+  @Ignore
+  public void testProgressiveOutput() throws Exception {
+    for (int i = 0; i < 20; i++) {
+      System.out.println("Emitting sysout line: " + i);
+      System.err.println("Emitting syserr line: " + i);
+      System.out.flush();
+      System.err.flush();
+      RandomizedTest.sleep(1000);
+    }
+  }
+
+  @Ignore
+  public void testUncaughtException() throws Exception {
+    Thread t = new Thread() {
+      @Override
+      public void run() {
+        throw new RuntimeException("foobar");
+      }
+    };
+    t.start();
+    t.join();
+  }
+  
+  @Ignore
+  @Timeout(millis = 500)
+  public void testTimeout() throws Exception {
+    Thread.sleep(5000);
+  }
+  
+  @Ignore
+  @Timeout(millis = 1000)
+  public void testZombie() throws Exception {
+    while (true) {
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException e) {}
+    }
+  }
+}

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java Mon Aug 13 08:18:11 2012
@@ -27,12 +27,9 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThreadInterruptedException;
 
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
-
 /**
  * Tests for {@link DocumentsWriterStallControl}
  */
-@ThreadLeaks(failTestIfLeaking = true)
 public class TestDocumentsWriterStallControl extends LuceneTestCase {
   
   public void testSimpleStall() throws InterruptedException {

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java Mon Aug 13 08:18:11 2012
@@ -67,14 +67,14 @@ public class TestReaderClosed extends Lu
       // expected
     }
   }
-  
+
   // LUCENE-3800
   public void testReaderChaining() throws Exception {
     assertTrue(reader.getRefCount() > 0);
     IndexReader wrappedReader = SlowCompositeReaderWrapper.wrap(reader);
+    wrappedReader = new ParallelAtomicReader((AtomicReader) wrappedReader);
 
     IndexSearcher searcher = newSearcher(wrappedReader);
-
     TermRangeQuery query = TermRangeQuery.newStringRange("field", "a", "z", true, true);
     searcher.search(query, 5);
     reader.close(); // close original child reader

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java Mon Aug 13 08:18:11 2012
@@ -60,6 +60,7 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.util.FixedBitSet;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.NamedThreadFactory;
 import org.apache.lucene.util._TestUtil;
 import org.junit.BeforeClass;
 
@@ -835,7 +836,7 @@ public class TestSort extends LuceneTest
     assertMatches (full, queryG, sort, "ZYXW");
 
     // Do the same for a ParallelMultiSearcher
-    ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random(), 2, 8));
+    ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random(), 2, 8), new NamedThreadFactory("testEmptyFieldSort"));
     IndexSearcher parallelSearcher=new IndexSearcher (full.getIndexReader(), exec);
 
     sort.setSort (new SortField ("int", SortField.Type.INT),
@@ -879,7 +880,7 @@ public class TestSort extends LuceneTest
 
   // test a variety of sorts using a parallel multisearcher
   public void testParallelMultiSort() throws Exception {
-    ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random(), 2, 8));
+    ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random(), 2, 8), new NamedThreadFactory("testParallelMultiSort"));
     IndexSearcher searcher = new IndexSearcher(
                                   new MultiReader(searchX.getIndexReader(),
                                                   searchY.getIndexReader()), exec);

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java Mon Aug 13 08:18:11 2012
@@ -160,7 +160,7 @@ public class TestWeakIdentityMap extends
   public void testConcurrentHashMap() throws Exception {
     // don't make threadCount and keyCount random, otherwise easily OOMs or fails otherwise:
     final int threadCount = 8, keyCount = 1024;
-    final ExecutorService exec = Executors.newFixedThreadPool(threadCount);
+    final ExecutorService exec = Executors.newFixedThreadPool(threadCount, new NamedThreadFactory("testConcurrentHashMap"));
     final WeakIdentityMap<Object,Integer> map =
       WeakIdentityMap.newConcurrentHashMap();
     // we keep strong references to the keys,

Modified: lucene/dev/branches/branch_4x/lucene/ivy-settings.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/ivy-settings.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/ivy-settings.xml Mon Aug 13 08:18:11 2012
@@ -19,6 +19,8 @@
 <ivysettings>
   <settings defaultResolver="default"/>
 
+  <property name="local-maven2-dir" value="${user.home}/.m2/repository/" />
+  
   <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
   <include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
   <include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
@@ -26,11 +28,22 @@
 
   <resolvers>
     <ibiblio name="sonatype-releases" root="http://oss.sonatype.org/content/repositories/releases" m2compatible="true" />
+
     <!-- you might need to tweak this from china so it works -->
     <ibiblio name="working-chinese-mirror" root="http://mirror.netcologne.de/maven2" m2compatible="true" />
 
+    <!--
+    <filesystem name="local-maven-2" m2compatible="true" local="true">
+      <artifact
+          pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
+      <ivy
+          pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].pom" />
+    </filesystem>
+    -->
+
     <chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
       <resolver ref="local"/>
+      <!-- <resolver ref="local-maven-2" /> -->
       <resolver ref="main"/>
       <resolver ref="sonatype-releases" />
       <resolver ref="working-chinese-mirror" />

Added: lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-2.0.0.rc5.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-2.0.0.rc5.jar.sha1?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-2.0.0.rc5.jar.sha1 (added)
+++ lucene/dev/branches/branch_4x/lucene/licenses/junit4-ant-2.0.0.rc5.jar.sha1 Mon Aug 13 08:18:11 2012
@@ -0,0 +1 @@
+2b08ce9fc1269cbbdbb647ec651d64d501d8c071
\ No newline at end of file

Added: lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-2.0.0.rc5.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-2.0.0.rc5.jar.sha1?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-2.0.0.rc5.jar.sha1 (added)
+++ lucene/dev/branches/branch_4x/lucene/licenses/randomizedtesting-runner-2.0.0.rc5.jar.sha1 Mon Aug 13 08:18:11 2012
@@ -0,0 +1 @@
+68dbb7c5d90e6b3606a4f207eefbd028d6a68c1a
\ No newline at end of file

Modified: lucene/dev/branches/branch_4x/lucene/module-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/module-build.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/module-build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/module-build.xml Mon Aug 13 08:18:11 2012
@@ -49,8 +49,8 @@
   <path id="test.classpath" refid="test.base.classpath"/>
 
   <path id="junit.classpath">
-    <path refid="test.classpath"/>
     <pathelement location="${build.dir}/classes/test"/>
+    <path refid="test.classpath"/>
     <pathelement path="${java.class.path}"/>
   </path>
 

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java Mon Aug 13 08:18:11 2012
@@ -39,6 +39,7 @@ import org.apache.lucene.store.AlreadyCl
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.English;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.NamedThreadFactory;
 
 /**
  * Spell checker test case
@@ -413,7 +414,7 @@ public class TestSpellChecker extends Lu
     int num_field2 = this.numdoc();
     assertEquals(num_field2, num_field1 + 1);
     int numThreads = 5 + random().nextInt(5);
-    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
+    ExecutorService executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("testConcurrentAccess"));
     SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
     for (int i = 0; i < numThreads; i++) {
       SpellCheckWorker spellCheckWorker = new SpellCheckWorker(r);

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/ivy.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/ivy.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/ivy.xml Mon Aug 13 08:18:11 2012
@@ -33,8 +33,8 @@
       <dependency org="org.apache.ant" name="ant-junit" rev="1.8.2" transitive="false" />
 
       <dependency org="junit" name="junit" rev="4.10" transitive="false" conf="default->*;junit4-stdalone->*" />
-            <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="1.6.0" transitive="false" conf="default->*;junit4-stdalone->*" />
-      <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="1.6.0" transitive="false" conf="default->*;junit4-stdalone->*" />
+      <dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="2.0.0.rc5" transitive="false" conf="default->*;junit4-stdalone->*" />
+      <dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="2.0.0.rc5" transitive="false" conf="default->*;junit4-stdalone->*" />
 
       <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/> 
     </dependencies>

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneJUnit3MethodProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneJUnit3MethodProvider.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneJUnit3MethodProvider.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneJUnit3MethodProvider.java Mon Aug 13 08:18:11 2012
@@ -17,13 +17,14 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import static com.carrotsearch.randomizedtesting.MethodCollector.flatten;
-import static com.carrotsearch.randomizedtesting.MethodCollector.mutableCopy1;
-
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
 
+import com.carrotsearch.randomizedtesting.ClassModel;
+import com.carrotsearch.randomizedtesting.ClassModel.MethodModel;
 import com.carrotsearch.randomizedtesting.TestMethodProvider;
 
 /**
@@ -31,20 +32,21 @@ import com.carrotsearch.randomizedtestin
  */
 public final class LuceneJUnit3MethodProvider implements TestMethodProvider {
   @Override
-  public Collection<Method> getTestMethods(Class<?> suiteClass, List<List<Method>> methods) {
-    // We will return all methods starting with test* and rely on further validation to weed
-    // out static or otherwise invalid test methods.
-    List<Method> copy = mutableCopy1(flatten(methods));
-    Iterator<Method> i =copy.iterator();
-    while (i.hasNext()) {
-      Method m= i.next();
-      if (!m.getName().startsWith("test") ||
-          !Modifier.isPublic(m.getModifiers()) ||
-           Modifier.isStatic(m.getModifiers()) ||
-           m.getParameterTypes().length != 0) {
-        i.remove();
+  public Collection<Method> getTestMethods(Class<?> suiteClass, ClassModel classModel) {
+    Map<Method,MethodModel> methods = classModel.getMethods();
+    ArrayList<Method> result = new ArrayList<Method>();
+    for (MethodModel mm : methods.values()) {
+      // Skip any methods that have overrieds/ shadows.
+      if (mm.getDown() != null) continue;
+
+      Method m = mm.element;
+      if (m.getName().startsWith("test") &&
+          Modifier.isPublic(m.getModifiers()) &&
+          !Modifier.isStatic(m.getModifiers()) &&
+          m.getParameterTypes().length == 0) {
+        result.add(m);
       }
     }
-    return copy;
+    return result;
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Mon Aug 13 08:18:11 2012
@@ -46,7 +46,13 @@ import org.junit.rules.TestRule;
 import org.junit.runner.RunWith;
 import com.carrotsearch.randomizedtesting.*;
 import com.carrotsearch.randomizedtesting.annotations.*;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakGroup.Group;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
+import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
 import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
 
 import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
@@ -114,7 +120,15 @@ import static com.carrotsearch.randomize
   RunListenerPrintReproduceInfo.class
 })
 @SeedDecorators({MixWithSuiteName.class}) // See LUCENE-3995 for rationale.
-@ThreadLeaks(failTestIfLeaking = false)
+@ThreadLeakScope(Scope.SUITE)
+@ThreadLeakGroup(Group.MAIN)
+@ThreadLeakAction({Action.WARN, Action.INTERRUPT})
+@ThreadLeakLingering(linger = 20000) // Wait long for leaked threads to complete before failure. zk needs this.
+@ThreadLeakZombies(Consequence.IGNORE_REMAINING_TESTS)
+@TimeoutSuite(millis = 10 * (/* minutes */ 1000 * 60)) // max suite execution time.
+@ThreadLeakFilters(defaultFilters = true, filters = {
+    QuickPatchThreadsFilter.class
+})
 public abstract class LuceneTestCase extends Assert {
 
   // --------------------------------------------------------------------
@@ -125,6 +139,7 @@ public abstract class LuceneTestCase ext
   public static final String SYSPROP_WEEKLY = "tests.weekly";
   public static final String SYSPROP_AWAITSFIX = "tests.awaitsfix";
   public static final String SYSPROP_SLOW = "tests.slow";
+  public static final String SYSPROP_BADAPPLES = "tests.badapples";
 
   /** @see #ignoreAfterMaxFailures*/
   private static final String SYSPROP_MAXFAILURES = "tests.maxfailures";
@@ -171,7 +186,21 @@ public abstract class LuceneTestCase ext
   @Retention(RetentionPolicy.RUNTIME)
   @TestGroup(enabled = true, sysProperty = SYSPROP_SLOW)
   public @interface Slow {}
-  
+
+  /**
+   * Annotation for tests that fail frequently. You can disable them
+   * if you want to run a long build and not stop on something that
+   * is a known problem.
+   * <pre>
+   * -Dtests.badapples=false
+   * </pre>
+   */
+  @Documented
+  @Inherited
+  @Retention(RetentionPolicy.RUNTIME)
+  @TestGroup(enabled = true, sysProperty = SYSPROP_BADAPPLES)
+  public @interface BadApple {}
+
   /**
    * Annotation for test classes that should avoid certain codec types
    * (because they are expensive, for example).
@@ -350,11 +379,16 @@ public abstract class LuceneTestCase ext
     .around(ignoreAfterMaxFailures)
     .around(suiteFailureMarker)
     .around(new TestRuleAssertionsRequired())
-    .around(new TestRuleNoStaticHooksShadowing())
-    .around(new TestRuleNoInstanceHooksOverrides())
+    .around(new NoClassHooksShadowingRule())
+    .around(new NoInstanceHooksOverridesRule() {
+      @Override
+      protected boolean verify(Method key) {
+        String name = key.getName();
+        return !(name.equals("setUp") || name.equals("tearDown"));
+      }
+    })
     .around(new SystemPropertiesInvariantRule(IGNORED_INVARIANT_PROPERTIES))
     .around(classNameRule = new TestRuleStoreClassName())
-    .around(new TestRuleReportUncaughtExceptions())
     .around(classEnvRule = new TestRuleSetupAndRestoreClassEnv());
 
 
@@ -381,7 +415,6 @@ public abstract class LuceneTestCase ext
     .outerRule(testFailureMarker)
     .around(ignoreAfterMaxFailures)
     .around(threadAndTestNameRule)
-    .around(new TestRuleReportUncaughtExceptions())
     .around(new SystemPropertiesInvariantRule(IGNORED_INVARIANT_PROPERTIES))
     .around(new TestRuleSetupAndRestoreInstanceEnv())
     .around(new TestRuleFieldCacheSanity())

Copied: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/QuickPatchThreadsFilter.java (from r1372246, lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/QuickPatchThreadsFilter.java?p2=lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/QuickPatchThreadsFilter.java&p1=lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java&r1=1372246&r2=1372307&rev=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/QuickPatchThreadsFilter.java Mon Aug 13 08:18:11 2012
@@ -1,5 +1,7 @@
 package org.apache.lucene.util;
 
+import com.carrotsearch.randomizedtesting.ThreadFilter;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -17,34 +19,17 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import com.carrotsearch.randomizedtesting.ClassValidator;
-
 /**
- * Require assertions for Lucene/Solr packages.
+ * Last minute patches.
+ * TODO: remove when integrated in system filters in rr.
  */
-public class TestRuleAssertionsRequired implements TestRule, ClassValidator {
-  @Override
-  public Statement apply(final Statement base, final Description description) {
-    return new Statement() {
-      @Override
-      public void evaluate() throws Throwable {
-        validate(description.getTestClass());
-        base.evaluate();
-      }
-    };
-  }
-
+public class QuickPatchThreadsFilter implements ThreadFilter {
   @Override
-  public void validate(Class<?> clazz) throws Throwable {
-    try {
-      assert false;
-      throw new Exception("Test class requires assertions, enable assertions globally (-ea) or for Solr/Lucene subpackages only.");
-    } catch (AssertionError e) {
-      // Ok, enabled.
-    }    
+  public boolean reject(Thread t) {
+    // MacOS system thread.
+    if (t.getName().equals("AWT-AppKit")) {
+      return true;
+    }
+    return false;
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleAssertionsRequired.java Mon Aug 13 08:18:11 2012
@@ -21,30 +21,24 @@ import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 
-import com.carrotsearch.randomizedtesting.ClassValidator;
-
 /**
  * Require assertions for Lucene/Solr packages.
  */
-public class TestRuleAssertionsRequired implements TestRule, ClassValidator {
+public class TestRuleAssertionsRequired implements TestRule {
   @Override
   public Statement apply(final Statement base, final Description description) {
     return new Statement() {
       @Override
       public void evaluate() throws Throwable {
-        validate(description.getTestClass());
+        try {
+          assert false;
+          throw new Exception("Test class requires assertions, enable assertions globally (-ea) or for Solr/Lucene subpackages only.");
+        } catch (AssertionError e) {
+          // Ok, enabled.
+        }
+
         base.evaluate();
       }
     };
   }
-
-  @Override
-  public void validate(Class<?> clazz) throws Throwable {
-    try {
-      assert false;
-      throw new Exception("Test class requires assertions, enable assertions globally (-ea) or for Solr/Lucene subpackages only.");
-    } catch (AssertionError e) {
-      // Ok, enabled.
-    }    
-  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/tools/custom-tasks.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/tools/custom-tasks.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/tools/custom-tasks.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/tools/custom-tasks.xml Mon Aug 13 08:18:11 2012
@@ -51,8 +51,9 @@
             <additional-filters />
 
             <!-- Typical version patterns. -->
+            <replaceregex pattern="\.rc[0-9]+" replace="" flags="gi" />
             <replaceregex pattern="\-(r)?([0-9\-\_\.])+(b(eta)?([0-9\-\.])*)?$" replace="" flags="gi" />
-    
+
             <!-- git hashcode pattern: its always 40 chars right? -->
             <replaceregex pattern="\-[a-z0-9]{40,40}$" replace="" flags="gi" />
           </filtermapper>

Added: lucene/dev/branches/branch_4x/lucene/tools/forbiddenApis/executors.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/tools/forbiddenApis/executors.txt?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/tools/forbiddenApis/executors.txt (added)
+++ lucene/dev/branches/branch_4x/lucene/tools/forbiddenApis/executors.txt Mon Aug 13 08:18:11 2012
@@ -0,0 +1,12 @@
+# These methods spawn threads with vague names. Use a custom thread factory and name
+# threads so that you can tell (by its name) which executor it is associated with.
+# see Solr's DefaultSolrThreadFactory
+# see Lucene's NamedThreadFactory
+
+java.util.concurrent.Executors#newFixedThreadPool(int)
+java.util.concurrent.Executors#newSingleThreadExecutor()
+java.util.concurrent.Executors#newCachedThreadPool()
+java.util.concurrent.Executors#newSingleThreadScheduledExecutor()
+java.util.concurrent.Executors#newScheduledThreadPool(int)
+java.util.concurrent.Executors#defaultThreadFactory()
+java.util.concurrent.Executors#privilegedThreadFactory()

Added: lucene/dev/branches/branch_4x/lucene/tools/junit4/logging.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/tools/junit4/logging.properties?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/tools/junit4/logging.properties (added)
+++ lucene/dev/branches/branch_4x/lucene/tools/junit4/logging.properties Mon Aug 13 08:18:11 2012
@@ -0,0 +1,10 @@
+
+# root handler
+handlers=java.util.logging.ConsoleHandler
+
+# root logger's cutoff threshold.
+.level=INFO
+
+# configure console handler to emit everything in the default format.
+java.util.logging.ConsoleHandler.level=FINEST
+java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

Modified: lucene/dev/branches/branch_4x/solr/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/build.xml?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/build.xml (original)
+++ lucene/dev/branches/branch_4x/solr/build.xml Mon Aug 13 08:18:11 2012
@@ -200,6 +200,7 @@
         <include name="jdk.txt" />
         <include name="jdk-deprecated.txt" />
         <include name="commons-io.txt" />
+        <include name="executors.txt" />
       </apiFileSet>
       <fileset dir="${basedir}/build">
         <include name="**/*.class" />

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java Mon Aug 13 08:18:11 2012
@@ -70,6 +70,7 @@ import org.apache.solr.update.processor.
 import org.apache.solr.update.processor.RunUpdateProcessorFactory;
 import org.apache.solr.update.processor.UpdateRequestProcessorChain;
 import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.plugin.NamedListInitializedPlugin;
 import org.apache.solr.util.plugin.PluginInfoInitialized;
@@ -1070,7 +1071,8 @@ public final class SolrCore implements S
   private final LinkedList<RefCounted<SolrIndexSearcher>> _searchers = new LinkedList<RefCounted<SolrIndexSearcher>>();
   private final LinkedList<RefCounted<SolrIndexSearcher>> _realtimeSearchers = new LinkedList<RefCounted<SolrIndexSearcher>>();
 
-  final ExecutorService searcherExecutor = Executors.newSingleThreadExecutor();
+  final ExecutorService searcherExecutor = Executors.newSingleThreadExecutor(
+      new DefaultSolrThreadFactory("searcherExecutor"));
   private int onDeckSearchers;  // number of searchers preparing
   // Lock ordering: one can acquire the openSearcherLock and then the searcherLock, but not vice-versa.
   private Object searcherLock = new Object();  // the sync object for the searcher

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java Mon Aug 13 08:18:11 2012
@@ -31,6 +31,7 @@ import org.apache.solr.common.params.Com
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.FastInputStream;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.solr.util.FileUtils;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.CachingDirectoryFactory.CloseListener;
@@ -178,7 +179,8 @@ public class SnapPuller {
         }
       }
     };
-    executorService = Executors.newSingleThreadScheduledExecutor();
+    executorService = Executors.newSingleThreadScheduledExecutor(
+        new DefaultSolrThreadFactory("snapPuller"));
     long initialDelay = pollInterval - (System.currentTimeMillis() % pollInterval);
     executorService.scheduleAtFixedRate(task, initialDelay, pollInterval, TimeUnit.MILLISECONDS);
     LOG.info("Poll Scheduled at an interval of " + pollInterval + "ms");
@@ -311,7 +313,7 @@ public class SnapPuller {
       LOG.info("Number of files in latest index in master: " + filesToDownload.size());
 
       // Create the sync service
-      fsyncService = Executors.newSingleThreadExecutor();
+      fsyncService = Executors.newSingleThreadExecutor(new DefaultSolrThreadFactory("fsyncService"));
       // use a synchronized list because the list is read by other threads (to show details)
       filesDownloaded = Collections.synchronizedList(new ArrayList<Map<String, Object>>());
       // if the generateion of master is older than that of the slave , it means they are not compatible to be copied

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Mon Aug 13 08:18:11 2012
@@ -397,7 +397,7 @@ public class SimpleFacets {
           Integer.MAX_VALUE,
           10, TimeUnit.SECONDS, // terminate idle threads after 10 sec
           new SynchronousQueue<Runnable>()  // directly hand off tasks
-          , new DefaultSolrThreadFactory("facetExectutor")
+          , new DefaultSolrThreadFactory("facetExecutor")
   );
   
   /**

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/CommitTracker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/CommitTracker.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/CommitTracker.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/CommitTracker.java Mon Aug 13 08:18:11 2012
@@ -29,6 +29,7 @@ import org.apache.solr.common.params.Mod
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,8 +53,8 @@ public final class CommitTracker impleme
   private int docsUpperBound;
   private long timeUpperBound;
   
-  private final ScheduledExecutorService scheduler = Executors
-      .newScheduledThreadPool(1);
+  private final ScheduledExecutorService scheduler = 
+      Executors.newScheduledThreadPool(1, new DefaultSolrThreadFactory("commitScheduler"));
   private ScheduledFuture pending;
   
   // state

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Mon Aug 13 08:18:11 2012
@@ -35,10 +35,12 @@ import org.apache.solr.common.cloud.Solr
 import org.apache.solr.common.cloud.ZkCoreNodeProps;
 import org.apache.solr.common.cloud.ZkNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 @Slow
@@ -315,7 +317,7 @@ public class LeaderElectionTest extends 
   @Test
   public void testStressElection() throws Exception {
     final ScheduledExecutorService scheduler = Executors
-        .newScheduledThreadPool(15);
+        .newScheduledThreadPool(15, new DefaultSolrThreadFactory("stressElection"));
     final List<ClientThread> threads = Collections
         .synchronizedList(new ArrayList<ClientThread>());
     
@@ -369,9 +371,7 @@ public class LeaderElectionTest extends 
             }
 
             Thread.sleep(10);
-            
           } catch (Exception e) {
-
           }
         }
       }
@@ -382,7 +382,6 @@ public class LeaderElectionTest extends 
       public void run() {
         
         while (!stopStress) {
-
           try {
             Thread.sleep(50);
             int j;
@@ -426,6 +425,7 @@ public class LeaderElectionTest extends 
     
     // cleanup any threads still running
     for (ClientThread thread : threads) {
+      thread.zkClient.getSolrZooKeeper().close();
       thread.close();
     }
     

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Mon Aug 13 08:18:11 2012
@@ -43,6 +43,7 @@ import org.apache.solr.common.cloud.ZkNo
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.handler.component.HttpShardHandlerFactory;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NodeExistsException;
@@ -298,7 +299,7 @@ public class OverseerTest extends SolrTe
 
       
       for (int i = 0; i < nodeCount; i++) {
-        nodeExecutors[i] = Executors.newFixedThreadPool(1);
+        nodeExecutors[i] = Executors.newFixedThreadPool(1, new DefaultSolrThreadFactory("testShardAssignment"));
       }
       
       final String[] ids = new String[coreCount];

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Mon Aug 13 08:18:11 2012
@@ -24,8 +24,6 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.common.SolrInputDocument;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,16 +34,7 @@ public class RecoveryZkTest extends Abst
   private static Logger log = LoggerFactory.getLogger(RecoveryZkTest.class);
   private StopableIndexingThread indexThread;
   private StopableIndexingThread indexThread2;
-  @BeforeClass
-  public static void beforeSuperClass() {
 
-  }
-  
-  @AfterClass
-  public static void afterSuperClass() {
-
-  }
-  
   public RecoveryZkTest() {
     super();
     sliceCount = 1;

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java Mon Aug 13 08:18:11 2012
@@ -37,7 +37,6 @@ public class TestMultiCoreConfBootstrap 
   protected CoreContainer cores = null;
   private String home;
 
-
   protected static ZkTestServer zkServer;
   protected static String zkDir;
   
@@ -101,7 +100,6 @@ public class TestMultiCoreConfBootstrap 
     super.tearDown();
   }
 
-
   @Test
   public void testMultiCoreConfBootstrap() throws Exception {
     System.setProperty("bootstrap_conf", "true");
@@ -113,6 +111,7 @@ public class TestMultiCoreConfBootstrap 
     assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
     assertTrue(zkclient.exists("/configs/core0/solrconfig.xml", true));
     assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
+    
+    zkclient.close();
   }
-
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java Mon Aug 13 08:18:11 2012
@@ -25,6 +25,7 @@ import org.apache.solr.request.SolrQuery
 import org.apache.solr.request.SolrRequestHandler;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.junit.Test;
 
@@ -163,7 +164,7 @@ public class SolrCoreTest extends SolrTe
 
     final int LOOP = 100;
     final int MT = 16;
-    ExecutorService service = Executors.newFixedThreadPool(MT);
+    ExecutorService service = Executors.newFixedThreadPool(MT, new DefaultSolrThreadFactory("refCountMT"));
     List<Callable<Integer>> callees = new ArrayList<Callable<Integer>>(MT);
     final CoreContainer cores = h.getCoreContainer();
     for (int i = 0; i < MT; ++i) {

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java Mon Aug 13 08:18:11 2012
@@ -49,6 +49,7 @@ import org.apache.solr.common.params.Mod
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.params.UpdateParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SolrjNamedThreadFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -71,7 +72,8 @@ public class ConcurrentUpdateSolrServer 
       .getLogger(ConcurrentUpdateSolrServer.class);
   private HttpSolrServer server;
   final BlockingQueue<UpdateRequest> queue;
-  final ExecutorService scheduler = Executors.newCachedThreadPool();
+  final ExecutorService scheduler = Executors.newCachedThreadPool(
+      new SolrjNamedThreadFactory("concurrentUpdateScheduler"));
   final Queue<Runner> runners;
   volatile CountDownLatch lock = null; // used to block everything
   final int threadCount;

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Mon Aug 13 08:18:11 2012
@@ -21,6 +21,7 @@ import org.apache.solr.client.solrj.*;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SolrjNamedThreadFactory;
 import org.apache.solr.common.SolrException;
 
 import java.io.IOException;
@@ -397,7 +398,7 @@ public class LBHttpSolrServer extends So
   public void setSoTimeout(int timeout) {
     HttpClientUtil.setSoTimeout(httpClient, timeout);
   }
-  
+
   @Override
   public void shutdown() {
     if (aliveCheckExecutor != null) {
@@ -555,7 +556,8 @@ public class LBHttpSolrServer extends So
     if (aliveCheckExecutor == null) {
       synchronized (this) {
         if (aliveCheckExecutor == null) {
-          aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor();
+          aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor(
+              new SolrjNamedThreadFactory("aliveCheckExecutor"));
           aliveCheckExecutor.scheduleAtFixedRate(
                   getAliveCheckRunner(new WeakReference<LBHttpSolrServer>(this)),
                   this.interval, this.interval, TimeUnit.MILLISECONDS);

Added: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/SolrjNamedThreadFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/SolrjNamedThreadFactory.java?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/SolrjNamedThreadFactory.java (added)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/SolrjNamedThreadFactory.java Mon Aug 13 08:18:11 2012
@@ -0,0 +1,49 @@
+package org.apache.solr.common.util;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class SolrjNamedThreadFactory implements ThreadFactory {
+  private static final AtomicInteger poolNumber = new AtomicInteger(1);
+  private final ThreadGroup group;
+  private final AtomicInteger threadNumber = new AtomicInteger(1);
+  private final String prefix;
+
+  public SolrjNamedThreadFactory(String namePrefix) {
+      SecurityManager s = System.getSecurityManager();
+      group = (s != null)? s.getThreadGroup() :
+                           Thread.currentThread().getThreadGroup();
+      prefix = namePrefix + "-" +
+                    poolNumber.getAndIncrement() +
+                   "-thread-";
+  }
+
+  public Thread newThread(Runnable r) {
+      Thread t = new Thread(group, r,
+                            prefix + threadNumber.getAndIncrement(),
+                            0);
+
+      t.setDaemon(false);
+      
+      if (t.getPriority() != Thread.NORM_PRIORITY)
+          t.setPriority(Thread.NORM_PRIORITY);
+      return t;
+  }
+}
\ No newline at end of file

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java Mon Aug 13 08:18:11 2012
@@ -19,9 +19,12 @@ package org.apache.zookeeper;
 
 import java.io.IOException;
 import java.nio.channels.SocketChannel;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 // we use this class to expose nasty stuff for tests
 public class SolrZooKeeper extends ZooKeeper {
+  List<Thread> spawnedThreads = new CopyOnWriteArrayList<Thread>();
 
   public SolrZooKeeper(String connectString, int sessionTimeout,
       Watcher watcher) throws IOException {
@@ -38,21 +41,32 @@ public class SolrZooKeeper extends ZooKe
    * @param ms the number of milliseconds to pause.
    */
   public void pauseCnxn(final long ms) {
-    new Thread() {
+    Thread t = new Thread() {
       public void run() {
-        synchronized (cnxn) {
-          try {
+        try {
+          synchronized (cnxn) {
             try {
               ((SocketChannel) cnxn.sendThread.sockKey.channel()).socket()
                   .close();
             } catch (Exception e) {
-
             }
             Thread.sleep(ms);
-          } catch (InterruptedException e) {}
-        }
+          }
+
+          // Wait a long while to make sure we properly clean up these threads.
+          Thread.sleep(500000);
+        } catch (InterruptedException e) {}
       }
-    }.start();
+    };
+    t.start();
+    spawnedThreads.add(t);
   }
 
+  @Override
+  public synchronized void close() throws InterruptedException {
+    for (Thread t : spawnedThreads) {
+      t.interrupt();
+    }
+    super.close();
+  }
 }

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java Mon Aug 13 08:18:11 2012
@@ -21,7 +21,9 @@ import junit.framework.Assert;
 import org.apache.commons.io.FileUtils;
 import org.apache.http.client.HttpClient;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
 import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.SolrIgnoredThreadsFilter;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
@@ -35,6 +37,8 @@ import org.apache.solr.util.AbstractSolr
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -48,6 +52,10 @@ import java.util.Set;
  * @since solr 1.4
  */
 @Slow
+@ThreadLeakFilters(defaultFilters = true, filters = {
+    SolrIgnoredThreadsFilter.class,
+    QuickPatchThreadsFilter.class
+})
 public class TestLBHttpSolrServer extends LuceneTestCase {
   SolrInstance[] solr = new SolrInstance[3];
   HttpClient httpClient;

Added: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java (added)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrIgnoredThreadsFilter.java Mon Aug 13 08:18:11 2012
@@ -0,0 +1,60 @@
+package org.apache.solr;
+
+import org.apache.lucene.search.TimeLimitingCollector.TimerThread;
+
+import com.carrotsearch.randomizedtesting.ThreadFilter;
+
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This ignores those threads in Solr for which there is no way to
+ * clean up after a suite.
+ */
+public class SolrIgnoredThreadsFilter implements ThreadFilter {
+  @Override
+  public boolean reject(Thread t) {
+    /*
+     * IMPORTANT! IMPORTANT!
+     * 
+     * Any threads added here should have ABSOLUTELY NO SIDE EFFECTS
+     * (should be stateless). This includes no references to cores or other
+     * test-dependent information.
+     */
+
+    String threadName = t.getName();
+    if (threadName.equals(TimerThread.THREAD_NAME)) {
+      return true;
+    }
+
+    if (threadName.startsWith("facetExecutor-") || 
+        threadName.startsWith("cmdDistribExecutor-") ||
+        threadName.startsWith("httpShardExecutor-")) {
+      return true;
+    }
+
+    // THESE ARE LIKELY BUGS - these threads should be closed!
+    if (threadName.startsWith("Overseer-") ||
+        threadName.startsWith("aliveCheckExecutor-") ||
+        threadName.startsWith("concurrentUpdateScheduler-")) {
+      return true;
+    }
+
+    return false;
+  }
+}

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Mon Aug 13 08:18:11 2012
@@ -24,6 +24,7 @@ import java.util.logging.*;
 import javax.xml.xpath.XPathExpressionException;
 
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
 import org.apache.noggit.*;
 import org.apache.solr.common.*;
 import org.apache.solr.common.cloud.SolrZkClient;
@@ -38,6 +39,7 @@ import org.apache.solr.schema.SchemaFiel
 import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.servlet.DirectSolrConnection;
 import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.RevertDefaultThreadHandlerRule;
 import org.apache.solr.util.TestHarness;
 import org.junit.*;
 import org.junit.rules.RuleChain;
@@ -46,20 +48,25 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
 import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 
 /**
  * A junit4 Solr test harness that extends LuceneTestCaseJ4.
  * Unlike {@link AbstractSolrTestCase}, a new core is not created for each test method.
  */
+@ThreadLeakFilters(defaultFilters = true, filters = {
+    SolrIgnoredThreadsFilter.class,
+    QuickPatchThreadsFilter.class
+})
 public abstract class SolrTestCaseJ4 extends LuceneTestCase {
   public static int DEFAULT_CONNECTION_TIMEOUT = 1000;  // default socket connection timeout in ms
 
 
   @ClassRule
   public static TestRule solrClassRules = 
-    RuleChain.outerRule(new SystemPropertiesRestoreRule());
+    RuleChain.outerRule(new SystemPropertiesRestoreRule())
+             .around(new RevertDefaultThreadHandlerRule());
 
   @Rule
   public TestRule solrTestRules = 

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Mon Aug 13 08:18:11 2012
@@ -31,7 +31,9 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.http.params.CoreConnectionPNames;
+import org.apache.lucene.util.LuceneTestCase.BadApple;
 import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -59,12 +61,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * 
  * TODO: we should still test this works as a custom update chain as well as
  * what we test now - the default update chain
- * 
  */
 @Slow
+@BadApple
+@AwaitsFix(bugUrl = "thread leaks") 
 public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTestBase {
   static Logger log = LoggerFactory.getLogger(AbstractFullDistribZkTestBase.class);
   

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java?rev=1372307&r1=1372306&r2=1372307&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java Mon Aug 13 08:18:11 2012
@@ -25,6 +25,8 @@ import java.util.*;
 import javax.xml.xpath.XPathExpressionException;
 
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.*;
 import org.apache.solr.common.params.CommonParams;
@@ -38,7 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
 import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 
 /**
@@ -54,6 +56,10 @@ import com.carrotsearch.randomizedtestin
  * @see #setUp
  * @see #tearDown
  */
+@ThreadLeakFilters(defaultFilters = true, filters = {
+    SolrIgnoredThreadsFilter.class,
+    QuickPatchThreadsFilter.class
+})
 public abstract class AbstractSolrTestCase extends LuceneTestCase {
   protected SolrConfig solrConfig;
 
@@ -98,7 +104,8 @@ public abstract class AbstractSolrTestCa
   
   @ClassRule
   public static TestRule solrClassRules = 
-    RuleChain.outerRule(new SystemPropertiesRestoreRule());
+    RuleChain.outerRule(new SystemPropertiesRestoreRule())
+             .around(new RevertDefaultThreadHandlerRule());
 
   @Rule
   public TestRule solrTestRules = 

Added: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RevertDefaultThreadHandlerRule.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RevertDefaultThreadHandlerRule.java?rev=1372307&view=auto
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RevertDefaultThreadHandlerRule.java (added)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RevertDefaultThreadHandlerRule.java Mon Aug 13 08:18:11 2012
@@ -0,0 +1,54 @@
+package org.apache.solr.util;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import com.carrotsearch.randomizedtesting.rules.StatementAdapter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public final class RevertDefaultThreadHandlerRule implements TestRule {
+  private final static AtomicBoolean applied = new AtomicBoolean();
+  
+  @Override
+  public Statement apply(Statement s, Description d) {
+    return new StatementAdapter(s) {
+      @Override
+      protected void before() throws Throwable {
+        if (!applied.getAndSet(true)) {
+          UncaughtExceptionHandler p = Thread.getDefaultUncaughtExceptionHandler();
+          try {
+            // Try to initialize a zookeeper class that reinitializes default exception handler.
+            Class<?> cl = org.apache.zookeeper.server.NIOServerCnxn.Factory.class;
+            // Make sure static initializers have been called.
+            Class.forName(cl.getName(), true, cl.getClassLoader());
+          } finally {
+            if (p == Thread.getDefaultUncaughtExceptionHandler()) {
+              throw new RuntimeException("Zookeeper no longer resets default thread handler.");
+            }
+            Thread.setDefaultUncaughtExceptionHandler(p);
+          }
+        }
+      }
+    };
+  }
+}