Repository: apache/kafka
File: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerMembershipManager.java (Java)

Code before:

    /**
     * {@inheritDoc}
     */
    @Override
    public void signalPartitionsBeingRevoked(Set<TopicPartition> partitionsToRevoke) {
        logPausedPartitionsBeingRevoked(partitionsToRevoke);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CompletableFuture<Void> signalPartitionsRevoked(Set<TopicPartition> partitionsRevoked) {
        return invokeOnPartitionsRevokedCallback(partitionsRevoked);
    }

    /**
     * Log partitions being revoked that were already paused, since the pause flag will be
     * effectively lost.
     */
    private void logPausedPartitionsBeingRevoked(Set<TopicPartition> partitionsToRevoke) {
        Set<TopicPartition> revokePausedPartitions = subscriptions.pausedPartitions();
        revokePausedPartitions.retainAll(partitionsToRevoke);
        if (!revokePausedPartitions.isEmpty() && log.isInfoEnabled()) {
            log.info("The pause flag in partitions [{}] will be removed due to revocation.", Utils.topicPartitionString(revokePausedPartitions));
        }
    }

    @Override
    public boolean isLeavingGroup() {
        CloseOptions.GroupMembershipOperation leaveGroupOperation = leaveGroupOperation();
        if (REMAIN_IN_GROUP == leaveGroupOperation) {
            return false;
        }

        MemberState state = state();
        boolean isLeavingState = state == MemberState.PREPARE_LEAVING || state == MemberState.LEAVING;

        // Default operation: both static and dynamic consumers will send a leave heartbeat
        boolean hasLeaveOperation = DEFAULT == leaveGroupOperation ||
            // Leave operation: both static and dynamic consumers will send a leave heartbeat
            LEAVE_GROUP == leaveGroupOperation ||
            // Remain in group: only static consumers will send a leave heartbeat, while dynamic members will not
            groupInstanceId().isPresent();

        return isLeavingState && hasLeaveOperation;
    }

    /**
     * Enqueue a {@link ConsumerRebalanceListenerCallbackNeededEvent} to trigger the execution of the

Review comment (suggestion):
Given that er end up printing the string in between [], can't we simply print the set directly?
```suggestion
            log.info("The pause flag in partitions {} will be removed due to revocation.", revokePausedPartitions);
```

Code after:

    /**
     * {@inheritDoc}
     */
    @Override
    public void signalPartitionsBeingRevoked(Set<TopicPartition> partitionsToRevoke) {
        logPausedPartitionsBeingRevoked(partitionsToRevoke);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CompletableFuture<Void> signalPartitionsRevoked(Set<TopicPartition> partitionsRevoked) {
        return invokeOnPartitionsRevokedCallback(partitionsRevoked);
    }

    /**
     * Log partitions being revoked that were already paused, since the pause flag will be
     * effectively lost.
     */
    private void logPausedPartitionsBeingRevoked(Set<TopicPartition> partitionsToRevoke) {
        Set<TopicPartition> revokePausedPartitions = subscriptions.pausedPartitions();
        revokePausedPartitions.retainAll(partitionsToRevoke);
        if (!revokePausedPartitions.isEmpty()) {
            log.info("The pause flag in partitions {} will be removed due to revocation.", revokePausedPartitions);
        }
    }

    @Override
    public boolean isLeavingGroup() {
        CloseOptions.GroupMembershipOperation leaveGroupOperation = leaveGroupOperation();
        if (REMAIN_IN_GROUP == leaveGroupOperation) {
            return false;
        }

        MemberState state = state();
        boolean isLeavingState = state == MemberState.PREPARE_LEAVING || state == MemberState.LEAVING;

        // Default operation: both static and dynamic consumers will send a leave heartbeat
        boolean hasLeaveOperation = DEFAULT == leaveGroupOperation ||
            // Leave operation: both static and dynamic consumers will send a leave heartbeat
            LEAVE_GROUP == leaveGroupOperation ||
            // Remain in group: only static consumers will send a leave heartbeat, while dynamic members will not
            groupInstanceId().isPresent();

        return isLeavingState && hasLeaveOperation;
    }

    /**
     * Enqueue a {@link ConsumerRebalanceListenerCallbackNeededEvent} to trigger the execution of the