chickenchickenlove commented on code in PR #23742:
URL: https://github.com/apache/kafka/pull/23742#discussion_r4370489227


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TargetAssignmentBuilder.java:
##########
@@ -158,10 +158,13 @@ private Assignment newMemberAssignment(
         String memberId
     ) {
         MemberAssignment newMemberAssignment = 
newGroupAssignment.members().get(memberId);
-        if (newMemberAssignment != null) {
-            return new Assignment(newMemberAssignment.partitions());
-        } else {
+        if (newMemberAssignment == null) {
             return Assignment.EMPTY;
         }
+
+        // The output is only read by the coordinator. Assignor inputs are
+        // reconstructed from target assignment records during replay.
+        // So, we don't need defensive copy here.
+        return Assignment.of(newMemberAssignment.partitions());

Review Comment:
   @squah-confluent 
   An earlier revision made a defensive copy here. I removed it after the 
discussion about whether it was necessary, reasoning that the coordinator only 
reads the output and reconstructs immutable assignments during replay.
   
   I hadn't fully considered assignor offloading. Since record building can be 
delayed until after another group invokes the assignor, I agree that we should 
restore the defensive copy here even if cost is quite expensive. 
   
   @dajac 
   What do you think?



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

Reply via email to