chia7712 commented on code in PR #19867:
URL: https://github.com/apache/kafka/pull/19867#discussion_r2158831000
##########
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,
Review Comment:
Using `Any` type would disable compiler from checking the input type. Could
you please do a bit refactor? for example:
```
def createResponseResponse(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)
}
def createResponseConfig(configs: AbstractConfig,
createConfigEntry: (String, Any) =>
DescribeConfigsResponseData.DescribeConfigsResourceResult):
DescribeConfigsResponseData.DescribeConfigsResult = {
val nonInternalValues = configs.nonInternalValues
val originalsFiltered = configs.originals.entrySet.stream()
.filter(e =>
e.getValue != null &&
!nonInternalValues.containsKey(e.getKey) // exclude keys
already in nonInternalValues
)
createResponseResponse(java.util.stream.Stream.concat(nonInternalValues.entrySet().stream(),
originalsFiltered), createConfigEntry)
}
def createResponseConfig(configs: java.util.Map[String, String],
createConfigEntry: (String, Any) =>
DescribeConfigsResponseData.DescribeConfigsResourceResult):
DescribeConfigsResponseData.DescribeConfigsResult = {
createResponseResponse(configs.entrySet().stream(),
createConfigEntry)
}
```
--
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]