diff --git a/kafka-admin/src/main/java/org/bf2/admin/kafka/admin/RecordOperations.java b/kafka-admin/src/main/java/org/bf2/admin/kafka/admin/RecordOperations.java index 813a27d2..f08cd7f4 100644 --- a/kafka-admin/src/main/java/org/bf2/admin/kafka/admin/RecordOperations.java +++ b/kafka-admin/src/main/java/org/bf2/admin/kafka/admin/RecordOperations.java @@ -133,11 +133,12 @@ public boolean hasNext() { } @Override - public ConsumerRecords next() throws NoSuchElementException { + public ConsumerRecords next() { var records = consumer.poll(Duration.ofMillis(100)); int pollSize = records.count(); emptyPoll = pollSize == 0; recordsConsumed.addAndGet(pollSize); + if (emptyPoll) { throw new NoSuchElementException(); } if (log.isTraceEnabled()) { log.tracef("next() consumed records: %d; total %s", pollSize, recordsConsumed.get()); }