m1a2st commented on code in PR #19867:
URL: https://github.com/apache/kafka/pull/19867#discussion_r2123485035
##########
core/src/main/scala/kafka/server/ConfigHelper.scala:
##########
@@ -87,18 +97,23 @@ class ConfigHelper(metadataCache: MetadataCache, config:
KafkaConfig, configRepo
includeDocumentation: Boolean):
List[DescribeConfigsResponseData.DescribeConfigsResult] = {
resourceToConfigNames.map { resource =>
- def createResponseConfig(configs: Map[String, 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
+ def createResponseConfig(configs: java.util.Map[String, _ <: Object],
+ createConfigEntry: (String, Object) =>
DescribeConfigsResponseData.DescribeConfigsResourceResult):
DescribeConfigsResponseData.DescribeConfigsResult = {
+ val configEntries:
java.util.List[DescribeConfigsResponseData.DescribeConfigsResourceResult] = {
+ val baseStream = configs.entrySet().stream()
+ val filtered = if (resource.configurationKeys == null ||
resource.configurationKeys.isEmpty) baseStream
+ else baseStream.filter(entry =>
resource.configurationKeys.contains(entry.getKey))
+
+ filtered
+
.map[DescribeConfigsResponseData.DescribeConfigsResourceResult](entry =>
+ createConfigEntry(entry.getKey, entry.getValue)
+ )
+ .toList
Review Comment:
What do you think about this adjustment?
```suggestion
configs.entrySet().stream()
.filter(entry =>
resource.configurationKeys == null ||
resource.configurationKeys.isEmpty ||
resource.configurationKeys.contains(entry.getKey)
)
.map[DescribeConfigsResponseData.DescribeConfigsResourceResult](entry =>
createConfigEntry(entry.getKey, entry.getValue)
)
.toList
```
--
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]