File tree Expand file tree Collapse file tree 3 files changed +22
-17
lines changed
core/src/test/org/apache/solr/cluster/events/impl
solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream
solrj/src/java/org/apache/solr/client/solrj/impl Expand file tree Collapse file tree 3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 2323import java .util .Collections ;
2424import java .util .concurrent .CountDownLatch ;
2525import java .util .concurrent .TimeUnit ;
26+ import org .apache .commons .io .IOUtils ;
2627import org .apache .solr .client .solrj .request .CollectionAdminRequest ;
2728import org .apache .solr .client .solrj .request .V2Request ;
2829import org .apache .solr .client .solrj .request .beans .PluginMeta ;
3637import org .apache .solr .core .CoreContainer ;
3738import org .apache .solr .embedded .JettySolrRunner ;
3839import org .apache .solr .util .LogLevel ;
40+ import org .junit .AfterClass ;
3941import org .junit .Before ;
4042import org .junit .BeforeClass ;
4143import 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 );
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments