Skip to content

Commit d1a8212

Browse files
authored
KAFKA-15873: Filter topics before sorting (#19304)
Partially addresses KAFKA-15873. When filtering and sorting, we should be applying the filter before the sort of topics. Order that unauthorizedForDescribeTopicMetadata is added to not relevant as it is a HashSet. Reviewers: TaiJuWu <[email protected]>, Calvin Liu <[email protected]>, Matthias J. Sax <[email protected]>
1 parent 1ebca78 commit d1a8212

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public DescribeTopicPartitionsResponseData handleDescribeTopicPartitionsRequest(
8989
// Do not disclose the existence of topics unauthorized for Describe, so we've not even checked if they exist or not
9090
Set<DescribeTopicPartitionsResponseTopic> unauthorizedForDescribeTopicMetadata = new HashSet<>();
9191

92-
Stream<String> authorizedTopicsStream = topics.stream().sorted().filter(topicName -> {
92+
Stream<String> authorizedTopicsStream = topics.stream().filter(topicName -> {
9393
boolean isAuthorized = authHelper.authorize(
9494
abstractRequest.context(), DESCRIBE, TOPIC, topicName, true, true, 1);
9595
if (!fetchAllTopics && !isAuthorized) {
@@ -99,7 +99,7 @@ public DescribeTopicPartitionsResponseData handleDescribeTopicPartitionsRequest(
9999
);
100100
}
101101
return isAuthorized;
102-
});
102+
}).sorted();
103103

104104
DescribeTopicPartitionsResponseData response = metadataCache.describeTopicResponse(
105105
authorizedTopicsStream.iterator(),

0 commit comments

Comments
 (0)