stanislavkozlovski commented on a change in pull request #9065: URL: https://github.com/apache/kafka/pull/9065#discussion_r459527097
########## File path: core/src/main/scala/kafka/cluster/Partition.scala ########## @@ -678,11 +678,13 @@ class Partition(val topicPartition: TopicPartition, isr: Set[Int], addingReplicas: Seq[Int], removingReplicas: Seq[Int]): Unit = { - remoteReplicasMap.clear() + val replicaSet = assignment.toSet + val removedReplicas = remoteReplicasMap.keys -- replicaSet + assignment .filter(_ != localBrokerId) .foreach(id => remoteReplicasMap.getAndMaybePut(id, new Replica(id, topicPartition))) - + removedReplicas.foreach(remoteReplicasMap.remove) Review comment: I decided to not get fancy with refactorings - this is literally the old code (https://github.com/apache/kafka/blob/7f9187fe399f3f6b041ca302bede2b3e780491e7/core/src/main/scala/kafka/cluster/Partition.scala#L657)) ---------------------------------------------------------------- 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