I use a Jetty server instance in my tests, and LTC almost always reports
that the 'qtp' threads are left open. 'qtp' are the prefix name of Jetty's
QueuedThreadPool threads. QueuedThreadPool has two defaults:

1) It is not daemon, therefore its PoolThreads are not set daemon too
2) It defaults to keep idle threads for 60 seconds around

In real-life these two settings make sense, but in tests, when I know that
I call server.stop only after all my tasks have completed, it's annoying.

When you call server.stop() followed by server.join(), it calls qtp.stop()
which interrupts all running PoolThreads. I'm not sure if there's a bug in
QueuedThreadPool's impl (or maybe PoolThread's impl), but I can tell for
sure that the JVM process keeps running for ~60 seconds, even though the
Socket and port have been released.

So I wrote this code in my tests that start a Server instance:

Server s = new Server();
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setDaemon(true); // I don't mind it'll be daemon in tests.
qtp.setMaxIdleTimeMs(0); // when a thread becomes idle, kill it
s.setThreadPool(qtp);

Yet, sometimes even that's not enough and LTC's afterClass is called before
the PoolThread dies. So I'm just thinking that if LTC would ignore daemon
threads, the annoying messages will be gone :).

It's not a big deal, just annoying to see these prints, and wasting so much
time trying to make them go away :).

Shai

On Thu, Feb 23, 2012 at 9:14 AM, Dawid Weiss
<dawid.we...@cs.put.poznan.pl>wrote:

> I think it should be closed gracefully, even if it's a daemon thread.
> Which thread do you have in mind?
>
> Dawid
>
> On Thu, Feb 23, 2012 at 7:33 AM, Shai Erera <ser...@gmail.com> wrote:
> > Hi
> >
> > I think that if a thread is daemon, but still running, LTC.threadCleanup
> > should not report it. What do you think?
> >
> > Shai
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: dev-h...@lucene.apache.org
>
>

Reply via email to