peterxcli commented on code in PR #18381:
URL: https://github.com/apache/kafka/pull/18381#discussion_r1920213345


##########
test-common/src/main/java/org/apache/kafka/common/test/KafkaClusterTestKit.java:
##########
@@ -206,35 +206,42 @@ private void setSecurityProtocolProps(Map<String, Object> 
props, String security
             }
         }
 
-        public KafkaClusterTestKit build() throws Exception {
-            Map<Integer, ControllerServer> controllers = new HashMap<>();
-            Map<Integer, BrokerServer> brokers = new HashMap<>();
-            Map<Integer, SharedServer> jointServers = new HashMap<>();
-            File baseDirectory = null;
-            File jaasFile = null;
-
+        private Optional<File> maybeSetupJaasFile() throws Exception {
             if 
(brokerSecurityProtocol.equals(SecurityProtocol.SASL_PLAINTEXT.name)) {
-                jaasFile = JaasUtils.writeJaasContextsToFile(Set.of(
+                File file = JaasUtils.writeJaasContextsToFile(Set.of(
                     new 
JaasUtils.JaasSection(JaasUtils.KAFKA_SERVER_CONTEXT_NAME,
                         List.of(
                             JaasModule.plainLoginModule(
-                                JaasUtils.KAFKA_PLAIN_ADMIN, 
JaasUtils.KAFKA_PLAIN_ADMIN_PASSWORD,
+                                JaasUtils.KAFKA_PLAIN_ADMIN, 
+                                JaasUtils.KAFKA_PLAIN_ADMIN_PASSWORD,
                                 true,
                                 Map.of(
                                     JaasUtils.KAFKA_PLAIN_USER1, 
JaasUtils.KAFKA_PLAIN_USER1_PASSWORD,
                                     JaasUtils.KAFKA_PLAIN_ADMIN, 
JaasUtils.KAFKA_PLAIN_ADMIN_PASSWORD)
-                                )
+                            )
                         )
                     )
                 ));
-                JaasUtils.refreshJavaLoginConfigParam(jaasFile);
+                JaasUtils.refreshJavaLoginConfigParam(file);
+                return Optional.of(file);
             }
+            return Optional.empty();
+        }
 
+        public KafkaClusterTestKit build() throws Exception {
+            Map<Integer, ControllerServer> controllers = new HashMap<>();
+            Map<Integer, BrokerServer> brokers = new HashMap<>();
+            Map<Integer, SharedServer> jointServers = new HashMap<>();
+            File baseDirectory = null;
+            Optional<File> jaasFile = maybeSetupJaasFile();

Review Comment:
   This is for resolving the NComplexity error.



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