Skip to content

Commit f772376

Browse files
committed
Random minor test fixes
1 parent db0cbd3 commit f772376

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Collections;
2424
import java.util.concurrent.CountDownLatch;
2525
import java.util.concurrent.TimeUnit;
26+
import org.apache.commons.io.IOUtils;
2627
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
2728
import org.apache.solr.client.solrj.request.V2Request;
2829
import org.apache.solr.client.solrj.request.beans.PluginMeta;
@@ -36,6 +37,7 @@
3637
import org.apache.solr.core.CoreContainer;
3738
import org.apache.solr.embedded.JettySolrRunner;
3839
import org.apache.solr.util.LogLevel;
40+
import org.junit.AfterClass;
3941
import org.junit.Before;
4042
import org.junit.BeforeClass;
4143
import org.junit.Test;
@@ -127,6 +129,17 @@ public void setUp() throws Exception {
127129
cluster.deleteAllCollections();
128130
}
129131

132+
@AfterClass
133+
public static void teardownCluster() throws Exception {
134+
CoreContainer cc = cluster.getOpenOverseer().getCoreContainer();
135+
cc.getClusterEventProducer().unregisterListener(eventsListener);
136+
IOUtils.close(eventsListener);
137+
if (repairListener != null) {
138+
cc.getClusterEventProducer().unregisterListener(repairListener);
139+
IOUtils.close(repairListener);
140+
}
141+
}
142+
130143
@Test
131144
public void testCollectionRepair() throws Exception {
132145
eventsListener.setExpectedType(ClusterEvent.EventType.COLLECTIONS_ADDED);

solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/BadClusterTest.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,21 @@ public void testBadCluster() throws Exception {
7979
}
8080

8181
private void testEmptyCollection() throws Exception {
82-
CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory);
83-
assertEquals(0, getTuples(stream).size());
82+
try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory)) {
83+
assertEquals(0, getTuples(stream).size());
84+
}
8485
}
8586

8687
private void testAllNodesDown() throws Exception {
87-
88-
CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory);
89-
cluster.expireZkSession(cluster.getReplicaJetty(getReplicas().get(0)));
90-
91-
try {
92-
getTuples(stream);
93-
fail("Expected IOException");
94-
} catch (IOException ioe) {
88+
try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory)) {
89+
cluster.expireZkSession(cluster.getReplicaJetty(getReplicas().get(0)));
90+
expectThrows(IOException.class, () -> getTuples(stream));
9591
}
9692
}
9793

9894
private void testClusterShutdown() throws Exception {
99-
100-
CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory);
101-
cluster.shutdown();
102-
103-
try {
95+
try (CloudSolrStream stream = new CloudSolrStream(buildSearchExpression(), streamFactory)) {
96+
cluster.shutdown();
10497
getTuples(stream);
10598
fail("Expected IOException: SolrException: TimeoutException");
10699
} catch (IOException ioe) {

solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,7 @@ private void moveAliveToDead(EndpointWrapper wrapper) {
845845
public void close() {
846846
synchronized (this) {
847847
if (aliveCheckExecutor != null) {
848-
aliveCheckExecutor.shutdownNow();
849-
ExecutorUtil.shutdownAndAwaitTermination(aliveCheckExecutor);
848+
ExecutorUtil.shutdownNowAndAwaitTermination(aliveCheckExecutor);
850849
}
851850
}
852851
ObjectReleaseTracker.release(this);

0 commit comments

Comments
 (0)