File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
solr/solrj/src/test/org/apache/solr/client/solrj/impl Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1717package org .apache .solr .client .solrj .impl ;
1818
1919import com .carrotsearch .randomizedtesting .RandomizedTest ;
20+ import java .util .Arrays ;
21+ import java .util .Objects ;
2022import java .util .Properties ;
23+ import java .util .Set ;
24+ import java .util .stream .Collectors ;
2125import org .apache .solr .SolrTestCaseJ4 ;
2226import org .apache .solr .client .solrj .SolrQuery ;
2327import org .apache .solr .client .solrj .cloud .SocketProxy ;
@@ -85,6 +89,16 @@ public void testProxyWithHttpSolrClientJdkImpl() throws Exception {
8589 }
8690 // This is a workaround for java.net.http.HttpClient not implementing closeable/autoclosable
8791 // until Java 21.
92+ Thread [] threads = new Thread [Thread .currentThread ().getThreadGroup ().activeCount ()];
93+ Thread .currentThread ().getThreadGroup ().enumerate (threads );
94+ Set <Thread > tSet =
95+ Arrays .stream (threads )
96+ .filter (Objects ::nonNull )
97+ .filter (t -> t .getName ().startsWith ("HttpClient-" ))
98+ .collect (Collectors .toSet ());
99+ for (Thread t : tSet ) {
100+ t .interrupt ();
101+ }
88102 System .gc ();
89103 }
90104
Original file line number Diff line number Diff line change 2424import java .net .http .HttpClient ;
2525import java .security .cert .CertificateException ;
2626import java .security .cert .X509Certificate ;
27+ import java .util .Arrays ;
2728import java .util .Collections ;
29+ import java .util .Objects ;
30+ import java .util .Set ;
2831import java .util .concurrent .ExecutorService ;
2932import java .util .concurrent .TimeUnit ;
33+ import java .util .stream .Collectors ;
3034import javax .net .ssl .KeyManagerFactory ;
3135import javax .net .ssl .SSLContext ;
3236import javax .net .ssl .SSLEngine ;
@@ -73,6 +77,16 @@ public static void beforeClass() {
7377
7478 @ After
7579 public void workaroundToReleaseThreads_noClosableUntilJava21 () {
80+ Thread [] threads = new Thread [Thread .currentThread ().getThreadGroup ().activeCount ()];
81+ Thread .currentThread ().getThreadGroup ().enumerate (threads );
82+ Set <Thread > tSet =
83+ Arrays .stream (threads )
84+ .filter (Objects ::nonNull )
85+ .filter (t -> t .getName ().startsWith ("HttpClient-" ))
86+ .collect (Collectors .toSet ());
87+ for (Thread t : tSet ) {
88+ t .interrupt ();
89+ }
7690 System .gc ();
7791 }
7892
You can’t perform that action at this time.
0 commit comments