akhileshchg commented on code in PR #13735: URL: https://github.com/apache/kafka/pull/13735#discussion_r1201206830
########## metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationZkWriter.java: ########## @@ -184,11 +232,36 @@ void handleTopicsDelta(Function<Uuid, String> deletedTopicNameResolver, TopicsDe topicDelta.partitionChanges(), migrationState)); } else { - operationConsumer.accept( - "Updating Partitions for Topic " + topicDelta.name() + ", ID " + topicId, - migrationState -> migrationClient.topicClient().updateTopicPartitions( - Collections.singletonMap(topicDelta.name(), topicDelta.partitionChanges()), - migrationState)); + if (topicDelta.hasPartitionsWithAssignmentChanges()) + operationConsumer.accept( + "Updating Topic " + topicDelta.name() + ", ID " + topicId, + migrationState -> migrationClient.topicClient().updateTopic( + topicDelta.name(), + topicId, + topicsImage.getTopic(topicId).partitions(), + migrationState)); + Map<Integer, PartitionRegistration> newPartitions = topicDelta.newPartitions(); + Map<Integer, PartitionRegistration> changedPartitions = topicDelta.partitionChanges(); + if (!newPartitions.isEmpty()) { + operationConsumer.accept( + "Create new partitions for Topic " + topicDelta.name() + ", ID " + topicId, + migrationState -> migrationClient.topicClient().createTopicPartitions( + Collections.singletonMap(topicDelta.name(), topicDelta.partitionChanges()), + migrationState)); + changedPartitions = changedPartitions + .entrySet() + .stream() + .filter(entry -> !newPartitions.containsKey(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + if (!changedPartitions.isEmpty()) { + Map<Integer, PartitionRegistration> finalChangedPartitions = changedPartitions; Review Comment: Yeah. We should have effectively final variable when we pass it to lambda. -- 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