From ee498f5a38c0454f6649e78f71c74d4bb2da1228 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Mon, 20 Aug 2018 13:17:05 +0530 Subject: [PATCH] SOLR-12679: MiniSolrCloudCluster.stopJettySolrRunner should remove jetty from the internal list While the startJettySolrRunner adds the given jetty instance to the internal list of jetty instances, the stopJettySolrRunner method does not remove the given instance from the list. This leads to inconsistencies such as stopped jettys retained in the internal list and duplicate (stopped) jettys. This commit also fixes TestCollectionsAPIViaSolrCloudCluster to deal with this change. --- solr/CHANGES.txt | 2 ++ .../collections/TestCollectionsAPIViaSolrCloudCluster.java | 2 +- .../java/org/apache/solr/cloud/MiniSolrCloudCluster.java | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 785dada1ba2..8f8ffc45eda 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -247,6 +247,8 @@ Bug Fixes * SOLR-12674: RollupStream should not use the HashQueryParser for 1 worker. (Varun Thacker) +* SOLR-12679: MiniSolrCloudCluster.stopJettySolrRunner should remove jetty from the internal list. (shalin) + Optimizations ---------------------- diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java index 067ec70b225..6ee616fd842 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java @@ -205,7 +205,7 @@ public class TestCollectionsAPIViaSolrCloudCluster extends SolrCloudTestCase { final CloudSolrClient client = cluster.getSolrClient(); assertNotNull(cluster.getZkServer()); - List jettys = cluster.getJettySolrRunners(); + List jettys = new ArrayList<>(cluster.getJettySolrRunners()); // make a copy assertEquals(nodeCount, jettys.size()); for (JettySolrRunner jetty : jettys) { assertTrue(jetty.isRunning()); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index df458d7877d..8b442db3083 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -427,8 +427,15 @@ public class MiniSolrCloudCluster { return jetty; } + /** + * Stop the given Solr instance. It will be removed from the cluster's list of running instances. + * @param jetty a {@link JettySolrRunner} to be stopped + * @return the same {@link JettySolrRunner} instance provided to this method + * @throws Exception on error + */ public JettySolrRunner stopJettySolrRunner(JettySolrRunner jetty) throws Exception { jetty.stop(); + jettys.remove(jetty); return jetty; }