You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/05/10 02:01:11 UTC

[solr] branch main updated: SOLR-16189: TestCancellableCollector thread leak (#847)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new f5e927ed1ed SOLR-16189: TestCancellableCollector thread leak (#847)
f5e927ed1ed is described below

commit f5e927ed1ed9cb43ac843cac4e12b6edc1b8a904
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Mon May 9 22:01:07 2022 -0400

    SOLR-16189: TestCancellableCollector thread leak (#847)
---
 .../org/apache/solr/search/TestCancellableCollector.java  | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java b/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
index d31ca82a07c..7e76bacc2ec 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
@@ -39,9 +39,9 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.TopScoreDocCollector;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NamedThreadFactory;
 import org.apache.solr.SolrTestCase;
 import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
 
 public class TestCancellableCollector extends SolrTestCase {
   Directory dir;
@@ -78,8 +78,8 @@ public class TestCancellableCollector extends SolrTestCase {
             4,
             0L,
             TimeUnit.MILLISECONDS,
-            new LinkedBlockingQueue<Runnable>(),
-            new NamedThreadFactory("TestIndexSearcher"));
+            new LinkedBlockingQueue<>(),
+            new SolrNamedThreadFactory(this.getClass().getSimpleName()));
   }
 
   @Override
@@ -89,10 +89,9 @@ public class TestCancellableCollector extends SolrTestCase {
     dir.close();
 
     if (executor != null) {
-      executor.shutdown();
+      ExecutorUtil.shutdownAndAwaitTermination(executor);
+      executor = null;
     }
-
-    executor = null;
   }
 
   private CancellableCollector buildCancellableCollector(
@@ -121,7 +120,6 @@ public class TestCancellableCollector extends SolrTestCase {
   private void cancelQuery(CancellableCollector cancellableCollector, final int sleepTime) {
     executor.submit(
         () -> {
-
           // Wait for some time to let the query start
           try {
             if (sleepTime > 0) {
@@ -130,6 +128,7 @@ public class TestCancellableCollector extends SolrTestCase {
 
             cancellableCollector.cancel();
           } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new RuntimeException(e.getMessage());
           }
         });
@@ -200,6 +199,7 @@ public class TestCancellableCollector extends SolrTestCase {
         try {
           Thread.sleep(50);
         } catch (InterruptedException e) {
+          Thread.currentThread().interrupt();
           throw new RuntimeException(e.getMessage());
         }
       }
@@ -212,6 +212,7 @@ public class TestCancellableCollector extends SolrTestCase {
             try {
               Thread.sleep(30);
             } catch (InterruptedException e) {
+              Thread.currentThread().interrupt();
               throw new RuntimeException(e.getMessage());
             }
           }