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


##########
core/src/test/java/kafka/test/junit/ClusterTestExtensions.java:
##########
@@ -162,32 +162,39 @@ private void processClusterTest(ExtensionContext context, 
ClusterTest annot, Clu
             controllers = annot.controllers();
         }
 
-        if (brokers <= 0 || controllers <= 0) {
-            throw new IllegalArgumentException("Number of brokers/controllers 
must be greater than zero.");
+        final int disksPerBroker;
+        if (annot.disksPerBroker() == 0) {
+            disksPerBroker = defaults.disksPerBroker();

Review Comment:
   We can leverage ternary conditional operator to make it more simple. For 
example:
   ```java
           Type type = annot.clusterType() == Type.DEFAULT ? 
defaults.clusterType() : annot.clusterType();
           Map<String, String> serverProperties = new HashMap<>();
           for (ClusterConfigProperty property : defaults.serverProperties()) {
               serverProperties.put(property.key(), property.value());
           }
           for (ClusterConfigProperty property : annot.serverProperties()) {
               serverProperties.put(property.key(), property.value());
           }
   
           ClusterConfig config = ClusterConfig.builder()
               .setType(type)
               .setBrokers(annot.brokers() == 0 ? defaults.brokers() : 
annot.brokers())
               .setControllers(annot.controllers() == 0 ? 
defaults.controllers() : annot.controllers())
               .setDisksPerBroker(annot.disksPerBroker() == 0 ? 
defaults.disksPerBroker() : annot.disksPerBroker())
               .setAutoStart(annot.autoStart() == AutoStart.DEFAULT ? 
defaults.autoStart() : annot.autoStart() == AutoStart.YES)
               .setName(annot.name().isEmpty() ? null : annot.name())
               .setName(annot.listener().isEmpty() ? null : annot.listener())
               .setServerProperties(serverProperties)
               .setSecurityProtocol(annot.securityProtocol())
               .setMetadataVersion(annot.metadataVersion())
               .build();
   
           type.invocationContexts(context.getRequiredTestMethod().getName(), 
config, testInvocations);
   ```



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