hachikuji commented on a change in pull request #8841: URL: https://github.com/apache/kafka/pull/8841#discussion_r441115973
########## File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java ########## @@ -675,36 +676,40 @@ private ListOffsetResult fetchOffsetsByTimes(Map<TopicPartition, Long> timestamp completedFetch.partition); } else { FetchPosition position = subscriptions.position(completedFetch.partition); - if (completedFetch.nextFetchOffset == position.offset) { - List<ConsumerRecord<K, V>> partRecords = completedFetch.fetchRecords(maxRecords); - - log.trace("Returning {} fetched records at offset {} for assigned partition {}", - partRecords.size(), position, completedFetch.partition); - - if (completedFetch.nextFetchOffset > position.offset) { - FetchPosition nextPosition = new FetchPosition( - completedFetch.nextFetchOffset, - completedFetch.lastEpoch, - position.currentLeader); - log.trace("Update fetching position to {} for partition {}", nextPosition, completedFetch.partition); - subscriptions.position(completedFetch.partition, nextPosition); - } + if (position != null) { Review comment: nit: maybe we could check for null first so that we avoid the nesting below (and reduce the diff) ```java if (position == null) throw new IllegalStateException("Missing position for fetchable partition " + completedFetch.partition); if (completedFetch.nextFetchOffset == position.offset) { ... ``` ---------------------------------------------------------------- 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