File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
solr/solrj/src/java/org/apache/solr/client/solrj/impl Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -410,14 +410,21 @@ private NamedList<Object> processErrorsAndResponse(
410410
411411 @ Override
412412 public void close () throws IOException {
413+ // If used with Java 21+
414+ if (httpClient instanceof AutoCloseable ) {
415+ try {
416+ ((AutoCloseable ) httpClient ).close ();
417+ } catch (Exception e ) {
418+ log .warn ("Could not close the http client." , e );
419+ }
420+ }
421+ httpClient = null ;
422+
413423 if (shutdownExecutor ) {
414424 ExecutorUtil .shutdownAndAwaitTermination (executor );
415425 }
416426 executor = null ;
417427
418- // TODO: Java 21 adds close/autoclosable to HttpClient. We should use it.
419- httpClient = null ;
420-
421428 assert ObjectReleaseTracker .release (this );
422429 }
423430
You can’t perform that action at this time.
0 commit comments