serhiy-bzhezytskyy commented on code in PR #4760:
URL: https://github.com/apache/solr/pull/4760#discussion_r3821239490


##########
solr/core/src/test/org/apache/solr/cloud/AddReplicaTest.java:
##########
@@ -106,7 +106,7 @@ public void testAddMultipleReplicas() throws Exception {
     docCollection = 
cloudClient.getClusterState().getCollectionOrNull(collection);
     assertNotNull(docCollection);
     // sanity check that everything is as before
-    assertEquals(9, docCollection.getReplicas().size());
+    assertEquals(9, docCollection.getReplicaStream().count());

Review Comment:
   Fair -- for this specific line there's no real win, you're right, 
`.getReplicaStream().count()` isn't fancier than `.getReplicas().size()` was. 
The method's main job is replacing the verbose 
`getSlices().stream().flatMap(slice -> slice.getReplicas().stream())` two-liner 
(73% of migrated call sites had that shape) -- this site just needed some 
replacement for the removed `getReplicas()`, and this is the plain flatten, not 
meant to do more.
   
   AI-assisted (Claude Sonnet 5)



##########
solr/core/src/test/org/apache/solr/cloud/AddReplicaTest.java:
##########
@@ -211,7 +211,13 @@ public void testAddReplicaWithUserDefinedProperties() 
throws Exception {
     // Verify that the new core was created with user-defined properties 
coming from the request
     // and inherited from the collection (the former taking precedence over 
the latter).
     Replica replica =
-        
cloudClient.getClusterState().getCollection(collectionName).getReplicas().get(1);
+        cloudClient
+            .getClusterState()
+            .getCollection(collectionName)
+            .getReplicaStream()
+            .skip(1)

Review Comment:
   Yes -- `.skip(1).findFirst()` is the exact Stream equivalent of the old 
`.get(1)` (0-indexed, second element). The assumption that the added replica 
lands at index 1 isn't new here, it's inherited from the original `.get(1)` -- 
unchanged by this migration.
   
   AI-assisted (Claude Sonnet 5)



-- 
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