dajac commented on code in PR #23505:
URL: https://github.com/apache/kafka/pull/23505#discussion_r4046225558


##########
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:
   works for me.



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