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


##########
core/src/test/java/kafka/test/ClusterConfig.java:
##########
@@ -139,28 +151,38 @@ public Map<String, String> nameTags() {
         return tags;
     }
 
-    public ClusterConfig copyOf() {
-        ClusterConfig copy = new ClusterConfig(type, brokers, controllers, 
name, autoStart, securityProtocol, listenerName, trustStoreFile, 
metadataVersion);
-        copy.serverProperties.putAll(serverProperties);
-        copy.producerProperties.putAll(producerProperties);
-        copy.consumerProperties.putAll(consumerProperties);
-        copy.saslServerProperties.putAll(saslServerProperties);
-        copy.saslClientProperties.putAll(saslClientProperties);
-        perBrokerOverrideProperties.forEach((brokerId, props) -> {
-            Properties propsCopy = new Properties();
-            propsCopy.putAll(props);
-            copy.perBrokerOverrideProperties.put(brokerId, propsCopy);
-        });
-        return copy;
+    public static Builder defaultBuilder() {
+        return new Builder()
+                .setType(Type.ZK)
+                .setBrokers(1)
+                .setControllers(1)
+                .setAutoStart(true)
+                .setSecurityProtocol(SecurityProtocol.PLAINTEXT)
+                .setMetadataVersion(MetadataVersion.latestTesting());
     }
 
-    public static Builder defaultClusterBuilder() {
-        return new Builder(Type.ZK, 1, 1, true, SecurityProtocol.PLAINTEXT, 
MetadataVersion.latestTesting());
+    public static Builder builder() {
+        return new Builder();
     }
 
-    public static Builder clusterBuilder(Type type, int brokers, int 
controllers, boolean autoStart,
-                                         SecurityProtocol securityProtocol, 
MetadataVersion metadataVersion) {
-        return new Builder(type, brokers, controllers, autoStart, 
securityProtocol, metadataVersion);
+    public static Builder builder(ClusterConfig clusterConfig) {

Review Comment:
   > Did you mean we shouldn't send ClusterConfig as an argument to builder ? 
If so, I can remove this method (i.e. L168). But that means we have to 
explicitly write all setters if we want to copy a ClusterConfig to a brand new 
one.
   And I'm not sure why this is error-prone. Would be appreciate if you can 
share more 😃 .
   
   that is a good helper method but we could neglect this copy-all when adding 
new field to `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