You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "psalagnac (via GitHub)" <gi...@apache.org> on 2025/11/04 16:11:51 UTC

[PR] SOLR-17931: Remove deprecated method in collection state classes [solr]

psalagnac opened a new pull request, #3834:
URL: https://github.com/apache/solr/pull/3834

   https://issues.apache.org/jira/browse/SOLR-17931
   
   
   # Description
   
   This removes some deprecated methods from `DocCollection` and related classes. Callers are adapted to use other similar methods when appropriate.
   
   Goal is to remove some deprecated code from Solr 10.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2504520781


##########
solr/core/src/java/org/apache/solr/cloud/ZkController.java:
##########
@@ -2069,15 +2070,26 @@ private void waitForShardId(final CoreDescriptor cd) {
     if (log.isDebugEnabled()) {
       log.debug("waiting to find shard id in clusterstate for {}", cd.getName());
     }
+
+    Predicate<Replica> replicaPredicate = (Replica r) -> cd.getName().equals(r.getCoreName());
     try {
       DocCollection collection =
           zkStateReader.waitForState(
               cd.getCollectionName(),
               320,
               TimeUnit.SECONDS,
-              c -> c != null && c.getShardId(getNodeName(), cd.getName()) != null);
+              c ->
+                  c != null
+                      && c.getReplicasOnNode(getNodeName()) != null

Review Comment:
   I changed this to never return null, and removed some now useless null checks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2492541935


##########
solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java:
##########
@@ -266,13 +267,13 @@ private List<SolrCmdDistributor.Node> lookupShardLeadersOfCollections() {
   }
 
   private SolrCmdDistributor.Node lookupShardLeaderOfCollection(String collection) {
-    final Slice[] activeSlices =
-        zkController.getClusterState().getCollection(collection).getActiveSlicesArr();
-    if (activeSlices.length == 0) {
+    final List<Slice> activeSlices =
+        new ArrayList<>(zkController.getClusterState().getCollection(collection).getActiveSlices());

Review Comment:
   why the ArrayList wrapper?



##########
solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java:
##########
@@ -327,8 +327,8 @@ private static List<Replica> getActiveReplicas(
     ClusterState clusterState = zkStateReader.getClusterState();
     Set<String> liveNodes = clusterState.getLiveNodes();
     final DocCollection docCollection = clusterState.getCollectionOrNull(collection);
-    if (docCollection != null && docCollection.getActiveSlicesArr().length > 0) {
-      final Slice[] activeSlices = docCollection.getActiveSlicesArr();
+    if (docCollection != null && !docCollection.getActiveSlices().isEmpty()) {
+      final Collection<Slice> activeSlices = docCollection.getActiveSlices();
       for (Slice next : activeSlices) {

Review Comment:
   This can be much simpler; one line not 3 and avoid the whole conditional check indentation.



##########
solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java:
##########
@@ -464,13 +463,13 @@ private boolean iAmInChargeOfPeriodicDeletes() {
     String col = desc.getCollectionName();
 
     DocCollection docCollection = zk.getClusterState().getCollection(col);
-    if (docCollection.getActiveSlicesArr().length == 0) {
+    if (docCollection.getActiveSlices().isEmpty()) {
       log.error("Collection {} has no active Slices?", col);
       return false;
     }
-    List<Slice> slices = new ArrayList<>(Arrays.asList(docCollection.getActiveSlicesArr()));
+    List<Slice> slices = new ArrayList<>(docCollection.getActiveSlices());

Review Comment:
   we don't need to create a new List and sort.  If you look at the code, the task is to find the first, sorted by name.  Streams can do that elegantly.



##########
solr/core/src/java/org/apache/solr/cloud/ZkController.java:
##########
@@ -2069,15 +2070,26 @@ private void waitForShardId(final CoreDescriptor cd) {
     if (log.isDebugEnabled()) {
       log.debug("waiting to find shard id in clusterstate for {}", cd.getName());
     }
+
+    Predicate<Replica> replicaPredicate = (Replica r) -> cd.getName().equals(r.getCoreName());
     try {
       DocCollection collection =
           zkStateReader.waitForState(
               cd.getCollectionName(),
               320,
               TimeUnit.SECONDS,
-              c -> c != null && c.getShardId(getNodeName(), cd.getName()) != null);
+              c ->
+                  c != null
+                      && c.getReplicasOnNode(getNodeName()) != null

Review Comment:
   hmm; maybe 'c.getReplicasOnNode' should return an empty collection to avoid awkward code like this, which raises potential concerns about double-calling a method that perhaps might not trivially return something.   WDYT?



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java:
##########
@@ -1119,8 +1120,9 @@ protected Map<String, Object> buildResponse(
     Map<String, Object> response = new HashMap<>();
 
     DocCollection coll = zkStateReader().getCollection(mutableId);
-    if (coll.getActiveSlicesArr().length > 0) {
-      String coreName = coll.getActiveSlicesArr()[0].getLeader().getCoreName();
+    if (!coll.getActiveSlices().isEmpty()) {
+      List<Slice> activeSlices = new ArrayList<>(coll.getActiveSlices());
+      String coreName = activeSlices.getFirst().getLeader().getCoreName();

Review Comment:
   why create an ArrayList wrapper?
   And can we call getActiveSlices once to avoid potential concerns of what work it may do?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2491360146


##########
solr/core/src/java/org/apache/solr/cloud/ZkController.java:
##########


Review Comment:
   I need to get on board the functional train!  I do find these long nested logic chains sometimes hard to understand.  But that's just me.



##########
solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java:
##########
@@ -464,13 +463,13 @@ private boolean iAmInChargeOfPeriodicDeletes() {
     String col = desc.getCollectionName();
 
     DocCollection docCollection = zk.getClusterState().getCollection(col);
-    if (docCollection.getActiveSlicesArr().length == 0) {
+    if (docCollection.getActiveSlices().isEmpty()) {
       log.error("Collection {} has no active Slices?", col);
       return false;
     }
-    List<Slice> slices = new ArrayList<>(Arrays.asList(docCollection.getActiveSlicesArr()));
+    List<Slice> slices = new ArrayList<>(docCollection.getActiveSlices());

Review Comment:
   Much nicer!



##########
solr/core/src/test/org/apache/solr/cloud/CreateRoutedAliasTest.java:
##########
@@ -156,8 +156,8 @@ public void testV2() throws Exception {
             .sum());
     // assertEquals(1, coll.getNumNrtReplicas().intValue()); // TODO seems to be erroneous; I
     // figured 'null'
-    assertEquals(1, coll.getNumTlogReplicas().intValue()); // per-shard
-    assertEquals(1, coll.getNumPullReplicas().intValue()); // per-shard
+    assertEquals(1, coll.getNumReplicas(Replica.Type.TLOG)); // per-shard

Review Comment:
   also nicer names!



##########
solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java:
##########
@@ -388,9 +378,9 @@ public Replica copyWith(PerReplicaStates.State state) {
   }
 
   public Replica copyWith(State state) {
-    Replica r = new Replica(name, propMap, collection, shard);
-    r.setState(state);
-    return r;
+    Map<String, Object> newProps = new LinkedHashMap<>(propMap);

Review Comment:
   just conifmring we need to make a newProps?



##########
solr/core/src/test/org/apache/solr/core/CoreSorterTest.java:
##########
@@ -141,12 +142,15 @@ public void integrationTest() {
       }
       @SuppressWarnings({"unchecked"})
       DocCollection col =
-          new DocCollection(
+          DocCollection.create(
               collection,
               sliceMap,
               Collections.singletonMap(
                   ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),
-              DocRouter.DEFAULT);
+              DocRouter.DEFAULT,

Review Comment:
   just out of curiosity, since I see the same pattern replaced over and over in this PR, is there a cleaner way to deal with the three new parameters to the `.create` method?  



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java:
##########
@@ -1119,8 +1120,9 @@ protected Map<String, Object> buildResponse(
     Map<String, Object> response = new HashMap<>();
 
     DocCollection coll = zkStateReader().getCollection(mutableId);
-    if (coll.getActiveSlicesArr().length > 0) {
-      String coreName = coll.getActiveSlicesArr()[0].getLeader().getCoreName();
+    if (!coll.getActiveSlices().isEmpty()) {
+      List<Slice> activeSlices = new ArrayList<>(coll.getActiveSlices());
+      String coreName = activeSlices.getFirst().getLeader().getCoreName();

Review Comment:
   I like the `.getFirst` versus teh magic array logic!  More expressive of what you are doing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac merged PR #3834:
URL: https://github.com/apache/solr/pull/3834


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2504510576


##########
solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java:
##########
@@ -327,8 +327,8 @@ private static List<Replica> getActiveReplicas(
     ClusterState clusterState = zkStateReader.getClusterState();
     Set<String> liveNodes = clusterState.getLiveNodes();
     final DocCollection docCollection = clusterState.getCollectionOrNull(collection);
-    if (docCollection != null && docCollection.getActiveSlicesArr().length > 0) {
-      final Slice[] activeSlices = docCollection.getActiveSlicesArr();
+    if (docCollection != null && !docCollection.getActiveSlices().isEmpty()) {
+      final Collection<Slice> activeSlices = docCollection.getActiveSlices();
       for (Slice next : activeSlices) {

Review Comment:
   Not sure I get your idea on this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2491534633


##########
solr/core/src/test/org/apache/solr/core/CoreSorterTest.java:
##########
@@ -141,12 +142,15 @@ public void integrationTest() {
       }
       @SuppressWarnings({"unchecked"})
       DocCollection col =
-          new DocCollection(
+          DocCollection.create(
               collection,
               sliceMap,
               Collections.singletonMap(
                   ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),
-              DocRouter.DEFAULT);
+              DocRouter.DEFAULT,

Review Comment:
   I think I can just live with it ;-).   This is all much cleaner anyway!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2505074928


##########
solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java:
##########
@@ -327,8 +327,8 @@ private static List<Replica> getActiveReplicas(
     ClusterState clusterState = zkStateReader.getClusterState();
     Set<String> liveNodes = clusterState.getLiveNodes();
     final DocCollection docCollection = clusterState.getCollectionOrNull(collection);
-    if (docCollection != null && docCollection.getActiveSlicesArr().length > 0) {
-      final Slice[] activeSlices = docCollection.getActiveSlicesArr();
+    if (docCollection != null && !docCollection.getActiveSlices().isEmpty()) {
+      final Collection<Slice> activeSlices = docCollection.getActiveSlices();
       for (Slice next : activeSlices) {

Review Comment:
   oh, I'm somewhat mistaken... need the docCollection null check.  But don't need the isEmpty check.
   This line:
   `      final Collection<Slice> activeSlices = docCollection.getActiveSlices();`
   Can go away by inlining the reference into the next line (the for loop).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2491525869


##########
solr/core/src/test/org/apache/solr/core/CoreSorterTest.java:
##########
@@ -141,12 +142,15 @@ public void integrationTest() {
       }
       @SuppressWarnings({"unchecked"})
       DocCollection col =
-          new DocCollection(
+          DocCollection.create(
               collection,
               sliceMap,
               Collections.singletonMap(
                   ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),
-              DocRouter.DEFAULT);
+              DocRouter.DEFAULT,

Review Comment:
   I was asking myself the same thing while doing the change.
   
   Another option was to introduce a new `create()` variant, with less parameters. But I did not do this since this method would be public in SolrJ, and the various calls to `create()` are only in tests.
   
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2500005318


##########
solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java:
##########
@@ -464,13 +463,13 @@ private boolean iAmInChargeOfPeriodicDeletes() {
     String col = desc.getCollectionName();
 
     DocCollection docCollection = zk.getClusterState().getCollection(col);
-    if (docCollection.getActiveSlicesArr().length == 0) {
+    if (docCollection.getActiveSlices().isEmpty()) {
       log.error("Collection {} has no active Slices?", col);
       return false;
     }
-    List<Slice> slices = new ArrayList<>(Arrays.asList(docCollection.getActiveSlicesArr()));
+    List<Slice> slices = new ArrayList<>(docCollection.getActiveSlices());

Review Comment:
   Good point. Retrieving the first element (== min) can be done without sorting the full list. That's more efficient.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2500033577


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java:
##########
@@ -1119,8 +1120,9 @@ protected Map<String, Object> buildResponse(
     Map<String, Object> response = new HashMap<>();
 
     DocCollection coll = zkStateReader().getCollection(mutableId);
-    if (coll.getActiveSlicesArr().length > 0) {
-      String coreName = coll.getActiveSlicesArr()[0].getLeader().getCoreName();
+    if (!coll.getActiveSlices().isEmpty()) {
+      List<Slice> activeSlices = new ArrayList<>(coll.getActiveSlices());
+      String coreName = activeSlices.getFirst().getLeader().getCoreName();

Review Comment:
   I was creating the ArrayList to easily get the first element.
   This may be avoided by using a stream or an iterator.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2505104409


##########
solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java:
##########
@@ -267,13 +267,13 @@ private List<SolrCmdDistributor.Node> lookupShardLeadersOfCollections() {
   }
 
   private SolrCmdDistributor.Node lookupShardLeaderOfCollection(String collection) {
-    final List<Slice> activeSlices =
-        new ArrayList<>(zkController.getClusterState().getCollection(collection).getActiveSlices());
+    final Collection<Slice> activeSlices =
+        zkController.getClusterState().getCollection(collection).getActiveSlices();
     if (activeSlices.isEmpty()) {
       throw new SolrException(
           SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Cannot route to collection " + collection);
     }
-    final Slice slice = activeSlices.getFirst();
+    final Slice slice = activeSlices.stream().findAny().orElseThrow();

Review Comment:
   Don't actually need an isEmpty check; can instead use the feature of Optional's `orElseThrow` that is overloaded to throw an exception.



##########
solr/core/src/test/org/apache/solr/cloud/MigrateReplicasTest.java:
##########
@@ -184,17 +183,14 @@ public void test() throws Exception {
     }
     // make sure all newly created replicas on node are active
     List<Replica> newReplicas = collection.getReplicasOnNode(nodeToBeDecommissioned);
-    assertNotNull("There should be replicas on the migrated-to node", newReplicas);
     assertFalse("There should be replicas on the migrated-to node", newReplicas.isEmpty());
     for (Replica r : newReplicas) {
       assertEquals(r.toString(), Replica.State.ACTIVE, r.getState());
     }
     // make sure all replicas on emptyNode are not active
     List<Replica> replicas = collection.getReplicasOnNode(emptyNode);

Review Comment:
   nit / taste: I love inlining to avoid needlessly declaring a variable (giving it a name and long scope); but I leave it to you (many places in the PR where we subsequently loop)



##########
solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java:
##########
@@ -314,9 +315,9 @@ public Map<String, Slice> getActiveSlicesMap() {
     return activeSlices;
   }
 
-  /** Get the list of replicas hosted on the given node or <code>null</code> if none. */
+  /** Get the list of replicas hosted on the given node, or an empty list if none. */
   public List<Replica> getReplicasOnNode(String nodeName) {
-    return nodeNameReplicas.get(nodeName);
+    return nodeNameReplicas.getOrDefault(nodeName, Collections.emptyList());

Review Comment:
   This is fine but nowadays I think we'd prefer the equivalent `List.of()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17931: Remove deprecated methods in collection state classes [solr]

Posted by "psalagnac (via GitHub)" <gi...@apache.org>.
psalagnac commented on code in PR #3834:
URL: https://github.com/apache/solr/pull/3834#discussion_r2491500362


##########
solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java:
##########
@@ -388,9 +378,9 @@ public Replica copyWith(PerReplicaStates.State state) {
   }
 
   public Replica copyWith(State state) {
-    Replica r = new Replica(name, propMap, collection, shard);
-    r.setState(state);
-    return r;
+    Map<String, Object> newProps = new LinkedHashMap<>(propMap);

Review Comment:
   Yes, since we don't want to touch the current replica. I think a `Replica` instance should be immutable (unfortunately, it is not fully). This change does a small step in this direction.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org