Copilot commented on code in PR #5501:
URL: https://github.com/apache/ignite-3/pull/5501#discussion_r2024637213


##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/PartitionReplicaLifecycleManager.java:
##########
@@ -689,6 +695,8 @@ private CompletableFuture<Set<Assignment>> 
calculateZoneAssignments(
                             zoneDescriptor.replicas()
                     ));
         });
+
+        return CompletableFuture.anyOf(stopReplicaLifecycleFuture, 
assignmentsFuture).thenApply(a -> (Set<Assignment>) a);

Review Comment:
   The use of CompletableFuture.anyOf with stopReplicaLifecycleFuture (of type 
Void) and assignmentsFuture (of type Set<Assignment>) may lead to a 
ClassCastException if stopReplicaLifecycleFuture ever completes normally. 
Ensure that stopReplicaLifecycleFuture is guaranteed to complete exceptionally 
to avoid unsafe casting.
   ```suggestion
           return CompletableFuture.anyOf(stopReplicaLifecycleFuture, 
assignmentsFuture).thenApply(a -> {
               if (a instanceof Set) {
                   return (Set<Assignment>) a;
               } else {
                   throw new IllegalStateException("Unexpected completion of 
stopReplicaLifecycleFuture");
               }
           });
   ```



-- 
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: notifications-unsubscr...@ignite.apache.org

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

Reply via email to