public CompletableFuture<Void> validatePositionsIfNeeded() {
        Map<TopicPartition, SubscriptionState.FetchPosition> partitionsToValidate =
                offsetFetcherUtils.getPartitionsToValidate();
        if (partitionsToValidate.isEmpty()) {
            return CompletableFuture.completedFuture(null);
        }

        return sendOffsetsForLeaderEpochRequestsAndValidatePositions(partitionsToValidate);
    }
Validate positions for all assigned partitions for which a leader change has been detected.
This will generate OffsetsForLeaderEpoch requests for the partitions, with the known offset
epoch and current leader epoch. It will enqueue the generated requests, to be sent on the
next call to {@link #poll(long)}.

<p/>

When a response is received, positions are validated and, if a log truncation is
detected, a {@link LogTruncationException} will be saved in memory, to be thrown on the
next call to this function.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetsRequestManager.java