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


##########
core/src/main/scala/kafka/server/ConfigHelper.scala:
##########
@@ -86,19 +81,34 @@ class ConfigHelper(metadataCache: MetadataCache, config: 
KafkaConfig, configRepo
                       includeSynonyms: Boolean,
                       includeDocumentation: Boolean): 
List[DescribeConfigsResponseData.DescribeConfigsResult] = {
     resourceToConfigNames.map { resource =>
-
-      def createResponseConfig(configs: Map[String, Any],
+      def createResponseConfig(configs: Any,
                                createConfigEntry: (String, Any) => 
DescribeConfigsResponseData.DescribeConfigsResourceResult): 
DescribeConfigsResponseData.DescribeConfigsResult = {
-        val filteredConfigPairs = if (resource.configurationKeys == null || 
resource.configurationKeys.isEmpty)
-          configs.toBuffer
-        else
-          configs.filter { case (configName, _) =>
-            resource.configurationKeys.asScala.contains(configName)
-          }.toBuffer
+        val stream = configs match {
+          case c: AbstractConfig =>
+            val nonInternalStream = c.nonInternalValues.entrySet.stream()
+            val originalsFiltered = c.originals.entrySet.stream()
+              .filter(e =>
+                e.getValue != null &&
+                  !c.nonInternalValues.containsKey(e.getKey) // exclude keys 
already in nonInternalValues

Review Comment:
   Perhaps we can move `nonInternalValues` out of the loop to avoid creating 
many `nonInternalValues`s?
   ```scala
             case c: AbstractConfig =>
               val nonInternalValues = c.nonInternalValues
               val originalsFiltered = c.originals.entrySet.stream()
                 .filter(e =>
                   e.getValue != null &&
                     !nonInternalValues.containsKey(e.getKey) // exclude keys 
already in nonInternalValues
                 )
               
java.util.stream.Stream.concat(nonInternalValues.entrySet().stream(), 
originalsFiltered)
   ```



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