AndrewJSchofield commented on code in PR #15479: URL: https://github.com/apache/kafka/pull/15479#discussion_r1514201905
########## clients/src/main/java/org/apache/kafka/clients/admin/internals/DeleteRecordsHandler.java: ########## @@ -79,15 +79,15 @@ public static SimpleAdminApiFuture<TopicPartition, DeletedRecords> newFuture( @Override public DeleteRecordsRequest.Builder buildBatchedRequest(int brokerId, Set<TopicPartition> keys) { Map<String, DeleteRecordsRequestData.DeleteRecordsTopic> deletionsForTopic = new HashMap<>(); - for (Map.Entry<TopicPartition, RecordsToDelete> entry: recordsToDelete.entrySet()) { - TopicPartition topicPartition = entry.getKey(); + for (TopicPartition topicPartition : keys) { + RecordsToDelete toDelete = recordsToDelete.get(topicPartition); DeleteRecordsRequestData.DeleteRecordsTopic deleteRecords = deletionsForTopic.computeIfAbsent( topicPartition.topic(), key -> new DeleteRecordsRequestData.DeleteRecordsTopic().setName(topicPartition.topic()) ); deleteRecords.partitions().add(new DeleteRecordsRequestData.DeleteRecordsPartition() .setPartitionIndex(topicPartition.partition()) - .setOffset(entry.getValue().beforeOffset())); + .setOffset(toDelete.beforeOffset())); Review Comment: Yes, in my opinion it would be unduly paranoid. I would end up writing conditional logic for a situation which will never occur, and it would differ from other code in this area of AdminClient which also uses a map which is accessed in this way confidently expecting the entry to be present. -- 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