dsmiley commented on code in PR #4760:
URL: https://github.com/apache/solr/pull/4760#discussion_r3822710610


##########
solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java:
##########
@@ -342,10 +343,12 @@ private CollectionAdminRequest.MoveReplica 
createMoveReplicaRequest(
   }
 
   private Replica getRandomReplica(String coll, CloudSolrClient cloudClient) 
throws IOException {
-    List<Replica> replicas = new ArrayList<>();
-    for (Slice slice : cloudClient.getClusterState().getCollection(coll)) {
-      replicas.addAll(slice.getReplicas());
-    }
+    List<Replica> replicas =
+        cloudClient
+            .getClusterState()
+            .getCollection(coll)
+            .getReplicaStream()
+            .collect(Collectors.toCollection(ArrayList::new));

Review Comment:
   Use the simpler toList() (which will be immutable): we don't need to 
manipulate the list merely to pick one at random



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to