showuon commented on code in PR #15924:
URL: https://github.com/apache/kafka/pull/15924#discussion_r1609187500
##########
core/src/main/scala/kafka/server/AclApis.scala:
##########
@@ -69,7 +69,7 @@ class AclApis(authHelper: AuthHelper,
case Some(auth) =>
val filter = describeAclsRequest.filter
val returnedAcls = new util.HashSet[AclBinding]()
- auth.acls(filter).forEach(returnedAcls.add)
+ returnedAcls.add(auth.acls(filter).iterator().next())
Review Comment:
OK, I know why you did this change now.
> we don't need to collect all items to a new collection, right?
I believe what @chia7712 meant is we don't have to do a collection copy here
because we already allow passing `Iterable` into `aclsResource` method. To make
it clear, in the JIRA, we said:
> 1. Iterable -> HashSet
This is the collection copy we want to avoid here. So we don't need
`returnedAcls` anymore, we can pass the result of `auth.acls(filter)` into
`aclsResource` directly. Is that clear?
##########
core/src/main/scala/kafka/server/AclApis.scala:
##########
@@ -69,7 +69,7 @@ class AclApis(authHelper: AuthHelper,
case Some(auth) =>
val filter = describeAclsRequest.filter
val returnedAcls = new util.HashSet[AclBinding]()
- auth.acls(filter).forEach(returnedAcls.add)
+ returnedAcls.add(auth.acls(filter).iterator().next())
Review Comment:
Originally we will add all `auth.acls(filter)` content into `returnedAcls`,
but after this change, we only add the first element. Why do we need this
change?
--
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]