public Exception invokePartitionsAssigned(final SortedSet<TopicPartition> assignedPartitions) {
        log.info("Adding newly assigned partitions: {}", assignedPartitions.stream().map(TopicPartition::toString).collect(Collectors.joining(", ")));

        Optional<ConsumerRebalanceListener> listener = subscriptions.rebalanceListener();

        if (listener.isPresent()) {
            try {
                final long startMs = time.milliseconds();
                listener.get().onPartitionsAssigned(assignedPartitions);
                metricsManager.recordPartitionsAssignedLatency(time.milliseconds() - startMs);
            } catch (WakeupException | InterruptException e) {
                throw e;
            } catch (Exception e) {
                log.error("User provided listener {} failed on invocation of onPartitionsAssigned for partitions {}",
                        listener.get().getClass().getName(), assignedPartitions, e);
                return e;
            }
        }

        return null;
    }
This class encapsulates the invocation of the callback methods defined in the {@link ConsumerRebalanceListener}
interface. When consumer group partition assignment changes, these methods are invoked. This class wraps those
callback calls with some logging, optional {@link Sensor} updates, etc.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerRebalanceListenerInvoker.java