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

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


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 56cf6d663d6 Random minor test fixes
56cf6d663d6 is described below

commit 56cf6d663d68b961b112bc5fad115f9e3e97d773
Author: Houston Putman <[email protected]>
AuthorDate: Thu Jan 30 15:45:26 2025 -0600

    Random minor test fixes
    
    (cherry picked from commit f7723767899cfc2976a17f63b8acd77780888600)
---
 .../impl/CollectionsRepairEventListenerTest.java   | 13 ++++++++++++
 .../client/solrj/io/stream/BadClusterTest.java     | 23 ++++++++--------------
 .../solr/client/solrj/impl/LBSolrClient.java       |  3 +--
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git 
a/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java
 
b/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java
index 64ed1005751..2aec62eaa7c 100644
--- 
a/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java
+++ 
b/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.request.V2Request;
 import org.apache.solr.client.solrj.request.beans.PluginMeta;
@@ -36,6 +37,7 @@ import org.apache.solr.cluster.events.ClusterEventProducer;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.embedded.JettySolrRunner;
 import org.apache.solr.util.LogLevel;
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -127,6 +129,17 @@ public class CollectionsRepairEventListenerTest extends 
SolrCloudTestCase {
     cluster.deleteAllCollections();
   }
 
+  @AfterClass
+  public static void teardownCluster() throws Exception {
+    CoreContainer cc = cluster.getOpenOverseer().getCoreContainer();
+    cc.getClusterEventProducer().unregisterListener(eventsListener);
+    IOUtils.close(eventsListener);
+    if (repairListener != null) {
+      cc.getClusterEventProducer().unregisterListener(repairListener);
+      IOUtils.close(repairListener);
+    }
+  }
+
   @Test
   public void testCollectionRepair() throws Exception {
     eventsListener.setExpectedType(ClusterEvent.EventType.COLLECTIONS_ADDED);
diff --git 
a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/BadClusterTest.java
 
b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/BadClusterTest.java
index b7c8b8a836c..562f46f5aab 100644
--- 
a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/BadClusterTest.java
+++ 
b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/BadClusterTest.java
@@ -80,28 +80,21 @@ public class BadClusterTest extends SolrCloudTestCase {
   }
 
   private void testEmptyCollection() throws Exception {
-    CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory);
-    assertEquals(0, getTuples(stream).size());
+    try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory)) {
+      assertEquals(0, getTuples(stream).size());
+    }
   }
 
   private void testAllNodesDown() throws Exception {
-
-    CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory);
-    cluster.expireZkSession(cluster.getReplicaJetty(getReplicas().get(0)));
-
-    try {
-      getTuples(stream);
-      fail("Expected IOException");
-    } catch (IOException ioe) {
+    try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory)) {
+      cluster.expireZkSession(cluster.getReplicaJetty(getReplicas().get(0)));
+      expectThrows(IOException.class, () -> getTuples(stream));
     }
   }
 
   private void testClusterShutdown() throws Exception {
-
-    CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory);
-    cluster.shutdown();
-
-    try {
+    try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), 
streamFactory)) {
+      cluster.shutdown();
       getTuples(stream);
       fail("Expected IOException: SolrException: TimeoutException");
     } catch (IOException ioe) {
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
index 921e41358e3..0b4f3a1523a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
@@ -887,8 +887,7 @@ public abstract class LBSolrClient extends SolrClient {
   public void close() {
     synchronized (this) {
       if (aliveCheckExecutor != null) {
-        aliveCheckExecutor.shutdownNow();
-        ExecutorUtil.shutdownAndAwaitTermination(aliveCheckExecutor);
+        ExecutorUtil.shutdownNowAndAwaitTermination(aliveCheckExecutor);
       }
     }
     ObjectReleaseTracker.release(this);

Reply via email to