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

hossman 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 3c44aa1e0ed SOLR-16751: ensure 'shards' list isn't included in props 
when creating DocCollection from JSON
3c44aa1e0ed is described below

commit 3c44aa1e0ed88c04fef4f6e8a88d933b9af790bd
Author: Chris Hostetter <[email protected]>
AuthorDate: Tue Apr 18 11:01:02 2023 -0700

    SOLR-16751: ensure 'shards' list isn't included in props when creating 
DocCollection from JSON
    
    (cherry picked from commit 501f69e72332cfbce98716be73b3913f1dcf645a)
---
 solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java     | 6 +++++-
 solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java 
b/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
index 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.java
index 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);

Reply via email to