C0urante commented on code in PR #14309:
URL: https://github.com/apache/kafka/pull/14309#discussion_r1586591574


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java:
##########
@@ -655,27 +811,38 @@ private static ConfigInfos validateClientOverrides(String 
connName,
         ConnectorClientConfigRequest connectorClientConfigRequest = new 
ConnectorClientConfigRequest(
             connName, connectorType, connectorClass, clientConfigs, 
clientType);
         List<ConfigValue> configValues = 
connectorClientConfigOverridePolicy.validate(connectorClientConfigRequest);
-        if (configValues != null) {
-            for (ConfigValue validatedConfigValue : configValues) {
-                ConfigKey configKey = 
configKeys.get(validatedConfigValue.name());
-                ConfigKeyInfo configKeyInfo = null;
-                if (configKey != null) {
-                    if (configKey.group != null) {
-                        groups.add(configKey.group);
-                    }
-                    configKeyInfo = convertConfigKey(configKey, prefix);
-                }
 
-                ConfigValue configValue = new ConfigValue(prefix + 
validatedConfigValue.name(), validatedConfigValue.value(),
-                                                          
validatedConfigValue.recommendedValues(), validatedConfigValue.errorMessages());
-                if (!configValue.errorMessages().isEmpty()) {
-                    errorCount++;
+        return prefixedConfigInfos(configDef.configKeys(), configValues, 
prefix);
+    }
+
+    private static ConfigInfos prefixedConfigInfos(Map<String, ConfigKey> 
configKeys, List<ConfigValue> configValues, String prefix) {
+        int errorCount = 0;
+        Set<String> groups = new LinkedHashSet<>();
+        List<ConfigInfo> configInfos = new ArrayList<>();
+
+        if (configValues == null) {
+            return new ConfigInfos("", 0, new ArrayList<>(groups), 
configInfos);
+        }
+
+        for (ConfigValue validatedConfigValue : configValues) {
+            ConfigKey configKey = configKeys.get(validatedConfigValue.name());
+            ConfigKeyInfo configKeyInfo = null;
+            if (configKey != null) {
+                if (configKey.group != null) {
+                    groups.add(configKey.group);
                 }
-                ConfigValueInfo configValueInfo = 
convertConfigValue(configValue, configKey != null ? configKey.type : null);
-                configInfoList.add(new ConfigInfo(configKeyInfo, 
configValueInfo));
+                configKeyInfo = convertConfigKey(configKey, prefix);
+            }
+
+            ConfigValue configValue = new ConfigValue(prefix + 
validatedConfigValue.name(), validatedConfigValue.value(),
+                    validatedConfigValue.recommendedValues(), 
validatedConfigValue.errorMessages());
+            if (configValue.errorMessages().size() > 0) {
+                errorCount++;
             }
+            ConfigValueInfo configValueInfo = convertConfigValue(configValue, 
configKey != null ? configKey.type : null);
+            configInfos.add(new ConfigInfo(configKeyInfo, configValueInfo));
         }
-        return new ConfigInfos(connectorClass.toString(), errorCount, new 
ArrayList<>(groups), configInfoList);
+        return new ConfigInfos("", errorCount, new ArrayList<>(groups), 
configInfos);

Review Comment:
   Yeah, it's a little weird with the empty string here. Hopefully it's fine 
for now but if we continue augmenting and refactoring this class I agree that 
it might be worth changing.



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