mirror of https://github.com/apache/lucene.git
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
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1050699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
623fd7bcd7
commit
50fe69c091
|
@ -469,10 +469,10 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
|
assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
|
||||||
setup = false;
|
setup = false;
|
||||||
Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);
|
|
||||||
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
||||||
if (!getClass().getName().startsWith("org.apache.solr"))
|
if (!getClass().getName().startsWith("org.apache.solr"))
|
||||||
threadCleanup("test method: '" + getName() + "'");
|
threadCleanup("test method: '" + getName() + "'");
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!uncaughtExceptions.isEmpty()) {
|
if (!uncaughtExceptions.isEmpty()) {
|
||||||
|
@ -527,9 +527,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
|
|
||||||
for (int i = 0; i < threadCount; i++) {
|
for (int i = 0; i < threadCount; i++) {
|
||||||
Thread t = stillRunning[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() &&
|
if (t.isAlive() &&
|
||||||
!rogueThreads.containsKey(t) &&
|
!rogueThreads.containsKey(t) &&
|
||||||
t != Thread.currentThread() &&
|
t != Thread.currentThread() &&
|
||||||
|
@ -539,7 +537,12 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
rogueThreads.put(t, true);
|
rogueThreads.put(t, true);
|
||||||
shouldFail = true;
|
shouldFail = true;
|
||||||
rogueCount++;
|
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:
|
// try to stop the thread:
|
||||||
|
t.setUncaughtExceptionHandler(null);
|
||||||
t.interrupt();
|
t.interrupt();
|
||||||
try {
|
try {
|
||||||
t.join(THREAD_STOP_GRACE_MSEC);
|
t.join(THREAD_STOP_GRACE_MSEC);
|
||||||
|
|
Loading…
Reference in New Issue