public void addAt(long offset, VoterSet voters) {
        Optional<LogHistory.Entry<VoterSet>> lastEntry = votersHistory.lastEntry();
        if (lastEntry.isPresent() && lastEntry.get().offset() >= 0) {
            // If the last voter set comes from the replicated log then the majorities must overlap.
            // This ignores the static voter set and the bootstrapped voter set since they come from
            // the configuration and the KRaft leader never guaranteed that they are the same across
            // all replicas.
            VoterSet lastVoterSet = lastEntry.get().value();
            if (!lastVoterSet.hasOverlappingMajority(voters)) {
                throw new IllegalArgumentException(
                    String.format(
                        "Last voter set %s doesn't have an overlapping majority with the new voter set %s",
                        lastVoterSet,
                        voters
                    )
                );
            }
        }

        votersHistory.addAt(offset, voters);
    }
Add a new value at a given offset.

The provided {@code offset} must be greater than or equal to 0 and must be greater than the
offset of all previous calls to this method.

@param offset the offset
@param voters the voters to store
@throws IllegalArgumentException if the offset is not greater than all previous offsets
raft/src/main/java/org/apache/kafka/raft/internals/VoterSetHistory.java