frankvicky commented on code in PR #22552:
URL: https://github.com/apache/kafka/pull/22552#discussion_r3414577966


##########
group-coordinator/group-coordinator-api/src/main/java/org/apache/kafka/coordinator/group/api/streams/StreamsGroupTopologyDescription.java:
##########
@@ -58,24 +59,24 @@ public sealed interface Node {
     public record Source(String name, Set<String> topics, Set<String> 
successors) implements Node {
         public Source {
             Objects.requireNonNull(name, "name");
-            topics = Set.copyOf(Objects.requireNonNull(topics, "topics"));
-            successors = Set.copyOf(Objects.requireNonNull(successors, 
"successors"));
+            topics = 
Collections.unmodifiableSet(Objects.requireNonNull(topics, "topics"));
+            successors = 
Collections.unmodifiableSet(Objects.requireNonNull(successors, "successors"));
         }
     }
 
     public record Processor(String name, Set<String> stores, Set<String> 
successors) implements Node {
         public Processor {
             Objects.requireNonNull(name, "name");
-            stores = Set.copyOf(Objects.requireNonNull(stores, "stores"));
-            successors = Set.copyOf(Objects.requireNonNull(successors, 
"successors"));
+            stores = 
Collections.unmodifiableSet(Objects.requireNonNull(stores, "stores"));
+            successors = 
Collections.unmodifiableSet(Objects.requireNonNull(successors, "successors"));
         }

Review Comment:
   there's no production caller that retains a mutable reference (the converter 
always constructs a fresh LinkedHashSet, tests pass Set.of(...)). Avoiding the 
defensive copy here is intentional



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