[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Jetty httpclient threads keeping program from ending
|
I have a little program utilizing SolrJ's Http2SolrClient which uses the
Jetty httpclient.
This is my little program:
https://paste.elyograg.org/view/f9bbe53c
If I run this, the program never ends. If I change Http2SolrClient to
HttpSolrClient (an older client utilizing Apache httpclient 4.x) and fix
the imports, then it ends. With HttpSolrClient, I do not need to
provide it with SSL configuration.
Background: we switched to the jetty client to gain http2 support. I
wasn't involved in that development, but I believe that the author chose
not to go with the version 5 Apache httpclient because at the time they
still did not have a stable release, and the jetty client at the time
had http2 support in stable releases for about three years.
A little bit of poking around yielded this output from jstack:
https://paste.elyograg.org/view/9b9bcc80
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. I think that the jetty client should mark the threads it
starts as daemon.
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.
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.
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.
Thanks,
Shawn