I've tried to switch from the 8.X to 9.3 solrj client library. At the same
time - I switched to Http2SolrClient since the other was marked deprecated.
We use the client in the pattern ...

try (SolrClient client =  createSolrClient()) {
  response = client.query(solrQuery);
  // do stuff with response
}

Which should  auto close the client to clean things up. But we've noticed
on tomcat shutdown this error in the logs ...

22-Aug-2023 11:22:04.645 SEVERE [Catalina-utility-1]
org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks
The web application [foo] created a ThreadLocal with key of type
[java.lang.ThreadLocal] (value [java.lang.ThreadLocal@727c756]) and a value
of type [org.eclipse.jetty.util.Pool.MonoEntry] (value [MonoEntry@2447031
{IDLE,pooled=RetainableByteBuffer@447004d6{DirectByteBuffer@6554e973[p=0,l=0,c=16384,r=0]={<<<>>>/16\\"","p...ce":"15},r=0}}])
but failed to remove it when the web application was stopped. Threads are
going to be renewed over time to try and avoid a probable memory leak.

Even worse, in another environment when left up long enough with lots or
queries ...  we eventually noticed an OutOfMemory error due to all the
ThreadLocal's which do not seem to be cleaned up.

I guess the question I have is
1) Is there a leak?
2) Is my usage wrong? Should I instead create a Singleton(ish) instance
used/shared by all the concurrent requests?
3) Other?

-Tim

Reply via email to