chia7712 commented on code in PR #15761:
URL: https://github.com/apache/kafka/pull/15761#discussion_r1573857883


##########
core/src/test/java/kafka/test/ClusterConfig.java:
##########
@@ -67,13 +69,16 @@ public class ClusterConfig {
         this.listenerName = listenerName;
         this.trustStoreFile = trustStoreFile;
         this.metadataVersion = metadataVersion;
-        this.serverProperties = copyOf(serverProperties);
-        this.producerProperties = copyOf(producerProperties);
-        this.consumerProperties = copyOf(consumerProperties);
-        this.adminClientProperties = copyOf(adminClientProperties);
-        this.saslServerProperties = copyOf(saslServerProperties);
-        this.saslClientProperties = copyOf(saslClientProperties);
-        perBrokerOverrideProperties.forEach((brokerId, props) -> 
this.perBrokerOverrideProperties.put(brokerId, copyOf(props)));
+        this.serverProperties = Collections.unmodifiableMap(serverProperties);
+        this.producerProperties = 
Collections.unmodifiableMap(producerProperties);
+        this.consumerProperties = 
Collections.unmodifiableMap(consumerProperties);
+        this.adminClientProperties = 
Collections.unmodifiableMap(adminClientProperties);
+        this.saslServerProperties = 
Collections.unmodifiableMap(saslServerProperties);
+        this.saslClientProperties = 
Collections.unmodifiableMap(saslClientProperties);
+        this.perBrokerOverrideProperties = Collections.unmodifiableMap(

Review Comment:
   The purpose of this PR is to make `ClusterConfig` be immutable. However, 
`ClusterConfig` have only immutable "view" of `serverProperties`, 
`producerProperties`, etc. It means `ClusterConfig` is still mutable object 
since callers can change inner variables of `ClusterConfig` by updating 
`ClusterConfig#Builder`. For example, user can call `putSaslServerProperty` to 
chagne `saslServerProperties` of `ClusterConfig`



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

Reply via email to