kirktrue commented on code in PR #14359: URL: https://github.com/apache/kafka/pull/14359#discussion_r1323610487
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java: ########## @@ -253,7 +248,7 @@ private Record nextFetchedRecord() { * @param maxRecords The number of records to return; the number returned may be {@code 0 <= maxRecords} * @return {@link ConsumerRecord Consumer records} */ - List<ConsumerRecord<K, V>> fetchRecords(int maxRecords) { + <K, V> List<ConsumerRecord<K, V>> fetchRecords(FetchConfig<K, V> fetchConfig, int maxRecords) { Review Comment: Done. ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CommitApplicationEvent.java: ########## @@ -19,46 +19,33 @@ import org.apache.kafka.clients.consumer.OffsetAndMetadata; import org.apache.kafka.common.TopicPartition; +import java.util.Collections; import java.util.Map; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -public class CommitApplicationEvent extends ApplicationEvent { - final private CompletableFuture<Void> future; - final private Map<TopicPartition, OffsetAndMetadata> offsets; +public class CommitApplicationEvent extends CompletableApplicationEvent<Void> { + + private final Map<TopicPartition, OffsetAndMetadata> offsets; public CommitApplicationEvent(final Map<TopicPartition, OffsetAndMetadata> offsets) { super(Type.COMMIT); - this.offsets = offsets; - Optional<Exception> exception = isValid(offsets); - if (exception.isPresent()) { - throw new RuntimeException(exception.get()); + this.offsets = Collections.unmodifiableMap(offsets); + for (OffsetAndMetadata offsetAndMetadata : offsets.values()) { + if (offsetAndMetadata.offset() < 0) { + throw new IllegalArgumentException("Invalid offset: " + offsetAndMetadata.offset()); + } } - this.future = new CompletableFuture<>(); - } - - public CompletableFuture<Void> future() { - return future; } public Map<TopicPartition, OffsetAndMetadata> offsets() { return offsets; } - private Optional<Exception> isValid(final Map<TopicPartition, OffsetAndMetadata> offsets) { - for (Map.Entry<TopicPartition, OffsetAndMetadata> entry : offsets.entrySet()) { - TopicPartition topicPartition = entry.getKey(); - OffsetAndMetadata offsetAndMetadata = entry.getValue(); - if (offsetAndMetadata.offset() < 0) { - return Optional.of(new IllegalArgumentException("Invalid offset: " + offsetAndMetadata.offset())); - } - } - return Optional.empty(); - } - @Override public String toString() { - return "CommitApplicationEvent(" - + "offsets=" + offsets + ")"; + return "CommitApplicationEvent{" + + "offsets=" + offsets + + ", future=" + future + + ", type=" + type + Review Comment: Done. -- 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