chia7712 commented on code in PR #19867: URL: https://github.com/apache/kafka/pull/19867#discussion_r2165808315
########## core/src/main/scala/kafka/server/ConfigHelper.scala: ########## @@ -82,25 +77,43 @@ class ConfigHelper(metadataCache: MetadataCache, config: KafkaConfig, configRepo new DescribeConfigsResponseData().setResults((authorizedConfigs ++ unauthorizedConfigs).asJava) } + private def buildDescribeConfigsResult(resource: DescribeConfigsResource, + configs: java.util.stream.Stream[java.util.Map.Entry[String, String]], + createConfigEntry: (String, Any) => DescribeConfigsResponseData.DescribeConfigsResourceResult): DescribeConfigsResponseData.DescribeConfigsResult = { + val configEntries = configs + .filter(entry => + resource.configurationKeys == null || + resource.configurationKeys.isEmpty || + resource.configurationKeys.contains(entry.getKey) + ) + .map[DescribeConfigsResponseData.DescribeConfigsResourceResult](entry => createConfigEntry(entry.getKey, entry.getValue)) + .toList + + new DescribeConfigsResponseData.DescribeConfigsResult() + .setErrorCode(Errors.NONE.code) + .setConfigs(configEntries) + } + + private def createResponseConfig(resource: DescribeConfigsResource, configs: AbstractConfig, + createConfigEntry: (String, Any) => DescribeConfigsResponseData.DescribeConfigsResourceResult): DescribeConfigsResponseData.DescribeConfigsResult = { + val nonInternalValues = configs.nonInternalValues // cache to avoid multiple calls + val nonInternalValuesStream = nonInternalValues.entrySet().stream() + .map(e => new java.util.AbstractMap.SimpleEntry[String, String](e.getKey, if (e.getValue == null) null else e.getValue.toString)) + val originalsFilteredStream = configs.originals.entrySet.stream() + .filter(e => e.getValue != null && !nonInternalValues.containsKey(e.getKey)) // skip keys in nonInternalValues + .map(e => new java.util.AbstractMap.SimpleEntry[String, String](e.getKey, if (e.getValue == null) null else e.getValue.toString)) Review Comment: > Would server/src/main/java/org/apache/kafka/server/ConfigHelperUtils.java be a good location for the helper methods? sounds good -- 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