squah-confluent commented on code in PR #23505:
URL: https://github.com/apache/kafka/pull/23505#discussion_r4045982769


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/TopicIds.java:
##########
@@ -226,12 +228,44 @@ public Iterator<Uuid> iterator() {
 
     @Override
     public Object[] toArray() {
-        throw new UnsupportedOperationException();
+        var topicIds = new Object[topicNames.size()];
+        var count = fill(topicIds);
+        return count == topicIds.length ? topicIds : Arrays.copyOf(topicIds, 
count);
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
-        throw new UnsupportedOperationException();
+        var size = topicNames.size();
+        var topicIds = a.length >= size
+            ? a
+            : (T[]) Array.newInstance(a.getClass().getComponentType(), size);
+        var count = fill(topicIds);
+        if (count < topicIds.length) {
+            if (topicIds == a) {
+                topicIds[count] = null;
+            } else {
+                topicIds = Arrays.copyOf(topicIds, count);
+            }
+        }
+        return topicIds;
+    }
+
+    /**
+     * Fills the array with the ids of the topic names which resolve, in the 
order of the names.
+     *
+     * @return The number of ids, which is below the size when a topic name 
has no id, its
+     *         topic having been deleted.

Review Comment:
   I'm not a fan of the wording. How about
   ```suggestion
        * Fills the array with the ids of the topics. Unresolvable topic names 
are skipped.
        *
        * @return The number of successfully resolved ids.
   ```
   
   Long explanation:
   * In this class we already resolve all topic names. The javadoc introduces 
another meaning of resolve here (resolved successfully).
   * Is the ordering important to the caller? The input is a set which 
typically does not have ordering guarantees.
   * "which ... when ..." is really tortured wording.



-- 
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]

Reply via email to