kirktrue commented on code in PR #19917: URL: https://github.com/apache/kafka/pull/19917#discussion_r2136356737
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/Utils.java: ########## @@ -20,12 +20,41 @@ import org.apache.kafka.common.TopicPartition; import java.io.Serializable; +import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; public final class Utils { + public static String sortedTopicPartitions(Collection<TopicPartition> partitions) { + SortedSet<TopicPartition> sortedPartitions; + + if (partitions instanceof SortedSet) { + sortedPartitions = (SortedSet<TopicPartition>) partitions; + } else { + sortedPartitions = new TreeSet<>(new TopicPartitionComparator()); + sortedPartitions.addAll(partitions); + } + + return join(sortedPartitions); + } + + private static String join(SortedSet<?> elements) { + StringBuilder b = new StringBuilder(); Review Comment: I made a change to use an `Iterable`/`Iterator` under the covers to leverage `String.join()`. -- 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