lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawid Weiss <>
Subject Re: Thread "leaking" in junit tests
Date Fri, 29 Jun 2012 08:14:10 GMT
> WARNING: test class left thread running:
> Thread[MultiThreadedHttpConnectionManager cleanup,5,main]
> I do not see such warnings in 4.x or trunk, how do I enable such warnings there?

Open LuceneTestCase and change this attribute to true:

@ThreadLeaks(failTestIfLeaking = false)

this will effectively kill those leaked threads and fail the test that
leaked them. Unfortunately the scenarios here are complex because
threads are started within a test scope and belong to suite scope (are
reused by all threads in a suite). Previously, the warnings were
detected for the suite scope only which would correspond to:

@ThreadLeaks(failTestIfLeaking = true, leakedThreadsBelongToSuite =
true, linger = 1000)


- fail a suite if threads leaked from it,
- if a thread leak occurs within a test, promote it to the suite scope,
- linger 1000 milliseconds before deciding a thread has leaked (this
is required for thread pools and such because they never wait for
their children threads to actually complete).

Many Solr and a few Lucene tests currently leak threads so the flag is
off. There is an issue to improve reporting of this (and handling of
this) here:

I just didn't get to it yet. Or rather: I did, but it requires changes
to the runner -- see here:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message