sjhajharia commented on code in PR #20156: URL: https://github.com/apache/kafka/pull/20156#discussion_r2268640599
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java: ########## @@ -4188,12 +4186,12 @@ private void expectRebalance(final Collection<String> revokedConnectors, if (connectProtocolVersion == CONNECT_PROTOCOL_V0) { assignment = new ExtendedAssignment( connectProtocolVersion, error, leader, leaderUrl, offset, - assignedConnectors, assignedTasks, - Collections.emptyList(), Collections.emptyList(), 0); + new ArrayList<>(assignedConnectors), new ArrayList<>(assignedTasks), + List.of(), List.of(), 0); } else { assignment = new ExtendedAssignment( connectProtocolVersion, error, leader, leaderUrl, offset, - assignedConnectors, assignedTasks, + new ArrayList<>(assignedConnectors), new ArrayList<>(assignedTasks), Review Comment: The ExtendedAssignment class assumes it can modify the collections it receives. When we pass immutable collections directly (due to changes made in this Test class to replace collections with List.of()), this assumption breaks and causes the UnsupportedOperationException. The deep copies bridge this gap by ensuring the API gets the mutable collections it expects while preserving the test's original data. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org