Apache Solr open-source search software
SOLR-16751: ensure 'shards' list isn't included in props when creating DocCollection from JSON
Chris Hostetter501f69e72332
diff --git a/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java b/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.javaindex 7acb960828a..28ffd0bd564 100644--- a/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java@@ -64,9 +64,13 @@ public class ClusterStateTest extends SolrTestCaseJ4 {"collection2", new DocCollection("collection2", slices, props, DocRouter.DEFAULT, 0, null));ClusterState clusterState = new ClusterState(liveNodes, collectionStates);+ assertFalse(clusterState.getCollection("collection1").getProperties().containsKey("shards"));+byte[] bytes = Utils.toJSON(clusterState);- // System.out.println("#################### " + new String(bytes));+ClusterState loadedClusterState = ClusterState.createFromJson(-1, bytes, liveNodes, null);+ assertFalse(+ loadedClusterState.getCollection("collection1").getProperties().containsKey("shards"));assertEquals("Provided liveNodes not used properly", 2, loadedClusterState.getLiveNodes().size());diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.javaindex 843bc1343e7..784acecd2ab 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java@@ -285,8 +285,8 @@ public class ClusterState implements JSONWriter.Writable {props = Collections.emptyMap();} else {slices = Slice.loadAllFromMap(name, sliceObjs);- props = new HashMap<>(objs);objs.remove(CollectionStateProps.SHARDS);+ props = new HashMap<>(objs);}Object routerObj = props.get(CollectionStateProps.DOC_ROUTER);