You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/12/18 20:43:47 UTC
svn commit: r1050699 -
/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
Author: rmuir
Date: Sat Dec 18 19:43:46 2010
New Revision: 1050699
URL: http://svn.apache.org/viewvc?rev=1050699&view=rev
Log:
LUCENE-2819: give rogue-threads left running after the test 1000ms to die naturally before we clear their exception handler and interrupt() them... perhaps they will fail nasty
Modified:
lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=1050699&r1=1050698&r2=1050699&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Sat Dec 18 19:43:46 2010
@@ -469,10 +469,10 @@ public abstract class LuceneTestCase ext
public void tearDown() throws Exception {
assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
setup = false;
- Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
if (!getClass().getName().startsWith("org.apache.solr"))
threadCleanup("test method: '" + getName() + "'");
+ Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);
try {
if (!uncaughtExceptions.isEmpty()) {
@@ -527,9 +527,7 @@ public abstract class LuceneTestCase ext
for (int i = 0; i < threadCount; i++) {
Thread t = stillRunning[i];
- // TODO: turn off our exception handler for these leftover threads... does this work?
- if (t != Thread.currentThread())
- t.setUncaughtExceptionHandler(null);
+
if (t.isAlive() &&
!rogueThreads.containsKey(t) &&
t != Thread.currentThread() &&
@@ -539,7 +537,12 @@ public abstract class LuceneTestCase ext
rogueThreads.put(t, true);
shouldFail = true;
rogueCount++;
+ // wait on the thread to die of natural causes
+ try {
+ t.join(THREAD_STOP_GRACE_MSEC);
+ } catch (InterruptedException e) { e.printStackTrace(); }
// try to stop the thread:
+ t.setUncaughtExceptionHandler(null);
t.interrupt();
try {
t.join(THREAD_STOP_GRACE_MSEC);