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


##########
core/src/main/scala/kafka/server/ConfigHelper.scala:
##########
@@ -96,11 +81,21 @@ class ConfigHelper(metadataCache: MetadataCache, config: 
KafkaConfig, configRepo
                       includeSynonyms: Boolean,
                       includeDocumentation: Boolean): 
List[DescribeConfigsResponseData.DescribeConfigsResult] = {
     resourceToConfigNames.map { resource =>
-
-      def createResponseConfig(configs: java.util.Map[String, _ <: Object],
+      def createResponseConfig(configs: Any,
                                createConfigEntry: (String, Object) => 
DescribeConfigsResponseData.DescribeConfigsResourceResult): 
DescribeConfigsResponseData.DescribeConfigsResult = {
+        val stream = configs match {
+          case c: AbstractConfig =>
+            java.util.stream.Stream.concat(
+              c.originals.entrySet.stream.filter(_.getValue != null),
+              
c.nonInternalValues.entrySet.stream.map(_.asInstanceOf[java.util.Map.Entry[String,
 Object]])
+            )
+          case m: java.util.Map[_, _] =>
+            m.asInstanceOf[java.util.Map[String, String]].entrySet().stream()
+          case _ => throw new IllegalArgumentException("Unsupported configs 
type")
+        }
+
         val configEntries: 
java.util.List[DescribeConfigsResponseData.DescribeConfigsResourceResult] = {

Review Comment:
   ```
           val configEntries = stream
               .filter(entry =>
                 resource.configurationKeys == null ||
                   resource.configurationKeys.isEmpty ||
                   resource.configurationKeys.contains(entry.getKey)
               )
               
.map[DescribeConfigsResponseData.DescribeConfigsResourceResult](entry => 
createConfigEntry(entry.getKey, entry.getValue))
               .toList
   ```



##########
core/src/main/scala/kafka/server/ConfigHelper.scala:
##########
@@ -96,11 +81,21 @@ class ConfigHelper(metadataCache: MetadataCache, config: 
KafkaConfig, configRepo
                       includeSynonyms: Boolean,
                       includeDocumentation: Boolean): 
List[DescribeConfigsResponseData.DescribeConfigsResult] = {
     resourceToConfigNames.map { resource =>
-
-      def createResponseConfig(configs: java.util.Map[String, _ <: Object],
+      def createResponseConfig(configs: Any,
                                createConfigEntry: (String, Object) => 
DescribeConfigsResponseData.DescribeConfigsResourceResult): 
DescribeConfigsResponseData.DescribeConfigsResult = {
+        val stream = configs match {
+          case c: AbstractConfig =>
+            java.util.stream.Stream.concat(
+              c.originals.entrySet.stream.filter(_.getValue != null),
+              
c.nonInternalValues.entrySet.stream.map(_.asInstanceOf[java.util.Map.Entry[String,
 Object]])

Review Comment:
   You might change the type of `createConfigEntry` from `(String, Object)` to 
`(String, Any)` to eliminate the extra type declaration.



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