Source:
private List<ConsumerRecord<K, V>> fetchRecords(CompletedFetch completedFetch, int maxRecords) { if (!subscriptions.isAssigned(completedFetch.partition)) { log.debug("Not returning fetched records for partition since it is no longer assigned", completedFetch.partition); } else if (!subscriptions.isFetchable(completedFetch.partition)) { log.debug("Not returning fetched records for assigned partition since it is no longer fetchable", completedFetch.partition); } else { SubscriptionState.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, position, completedFetch.partition); if (completedFetch.nextFetchOffset > position.offset) { SubscriptionState.FetchPosition nextPosition = new SubscriptionState.FetchPosition( completedFetch.nextFetchOffset, completedFetch.lastEpoch, position.currentLeader); log.trace("Update fetching position to for partition {}", nextPosition, completedFetch.partition); subscriptions.position(completedFetch.partition, nextPosition); } Long partitionLag = subscriptions.partitionLag(completedFetch.partition, isolationLevel); if (partitionLag != null) this.sensors.recordPartitionLag(completedFetch.partition, partitionLag); Long lead = subscriptions.partitionLead(completedFetch.partition); if (lead != null) { this.sensors.recordPartitionLead(completedFetch.partition, lead); } return partRecords; } else { log.debug("Ignoring fetched records for at offset since the current position is {}", completedFetch.partition, completedFetch.nextFetchOffset, position); } } log.trace("Draining fetched records for partition {}", completedFetch.partition); completedFetch.drain(); return emptyList(); }

Target:
private List<ConsumerRecord<K, V>> fetchRecords(CompletedFetch completedFetch, int maxRecords) { if (!subscriptions.isAssigned(completedFetch.partition)) { log.debug("Not returning fetched records for partition since it is no longer assigned", completedFetch.partition); } else if (!subscriptions.isFetchable(completedFetch.partition)) { log.debug("Not returning fetched records for assigned partition since it is no longer fetchable", completedFetch.partition); } else { SubscriptionState.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) { SubscriptionState.FetchPosition nextPosition = new SubscriptionState.FetchPosition( completedFetch.nextFetchOffset, completedFetch.lastEpoch, position.currentLeader); log.trace("Update fetching position to for partition {}", nextPosition, completedFetch.partition); subscriptions.position(completedFetch.partition, nextPosition); } Long partitionLag = subscriptions.partitionLag(completedFetch.partition, isolationLevel); if (partitionLag != null) this.sensors.recordPartitionLag(completedFetch.partition, partitionLag); Long lead = subscriptions.partitionLead(completedFetch.partition); if (lead != null) { this.sensors.recordPartitionLead(completedFetch.partition, lead); } return partRecords; } else { log.debug("Ignoring fetched records for at offset since the current position is {}", completedFetch.partition, completedFetch.nextFetchOffset, position); } } log.trace("Draining fetched records for partition {}", completedFetch.partition); completedFetch.drain(); return emptyList(); }