Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty httpclient threads keeping program from ending

Hi,

On Mon, Dec 26, 2022 at 5:13 PM Shawn Heisey <eclipse@xxxxxxxxxxxx> wrote:
> I believe the problem is that the threads the Jetty httpcient starts are
> not classified as Daemon threads, so when the main thread exits, they
> keep running.

Correct.

> I think that the jetty client should mark the threads it
> starts as daemon.

Some would like this, for others this is not good.

> If I uncomment the last statement in the program, which closes the solr
> client (and by extension closing the httpclient), then the program ends
> as expected.

Perhaps you are referring to a different version of the program?
The one linked is just a System.out, so it won't close the client.

> I know someone is going to tell me that I'm breaking the rules by not
> cleaning up the things I started.  In a long running program that
> occasionally creates a client, I would completely agree with that
> sentiment.  For quick and dirty things like what I have here, or for a
> long-running program that uses the same client for its entire life, I
> don't think it's unusual to let Java handle the final cleanup as it exits.

As I said, no one size fits all.

> Is there something we could have done in Http2SolrClient that would tell
> the Jetty client to use daemon threads, or would it take a feature
> request here for that?  I have not dived into the code to see what's
> available.

It is possible with Jetty's HttpClient and HTTP2Client to configure
the Executor so that the threads are daemon, but this is not exposed
by the Solr wrappers.
At this point you have to ask the Solr project to make their wrapper a
bit more configurable.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top