private void assignStickyPartitions() {
        groupSpec.memberIds().forEach(memberId ->
            groupSpec.memberAssignment(memberId).partitions().forEach((topicId, currentAssignment) -> {
                if (groupSpec.memberSubscription(memberId).subscribedTopicIds().contains(topicId)) {
                    currentAssignment.forEach(partition -> {
                        TopicIdPartition topicIdPartition = new TopicIdPartition(topicId, partition);
                        assignmentManager.addPartitionToTargetAssignment(topicIdPartition, memberId);
                        assignedStickyPartitions.add(topicIdPartition);
                    });
                } else {
                    LOG.debug("The topic " + topicId + " is no longer present in the subscribed topics list");
                }
            })
        );
    }
Gets a set of partitions that are to be retained from the existing assignment. This includes:
<li> Partitions from topics that are still present in both the new subscriptions and the topic metadata. </li>
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java