satishd commented on a change in pull request #10218: URL: https://github.com/apache/kafka/pull/10218#discussion_r610454559
########## File path: clients/src/test/java/org/apache/kafka/test/TestUtils.java ########## @@ -535,4 +536,46 @@ public static void setFieldValue(Object obj, String fieldName, Object value) thr field.setAccessible(true); field.set(obj, value); } + + /** + * Returns true if both iterators have same elements in the same order. + * + * @param iterator1 first iterator. + * @param iterator2 second iterator. + * @param <T> type of element in the iterators. + */ + public static <T> boolean sameElementsWithOrder(Iterator<T> iterator1, Review comment: IMHO, existing code looks easy to read/comprehend, and no multiple calls to hasNext(). How about the below code after removing inline variables in the existing code? ``` while (iterator1.hasNext()) { if (!iterator2.hasNext()) { return false; } if (!Objects.equals(iterator1.next(), iterator2.next())) { return false; } } return !iterator2.hasNext(); ``` -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org