private void handleBatch(Batch<?> batch, OptionalLong overrideOffset) {
        int offsetDelta = 0;
        for (ControlRecord record : batch.controlRecords()) {
            long currentOffset = overrideOffset.orElse(batch.baseOffset() + offsetDelta);
            switch (record.type()) {
                case KRAFT_VOTERS:
                    synchronized (voterSetHistory) {
                        voterSetHistory.addAt(currentOffset, VoterSet.fromVotersRecord((VotersRecord) record.message()));
                    }
                    break;

                case KRAFT_VERSION:
                    synchronized (kraftVersionHistory) {
                        kraftVersionHistory.addAt(
                            currentOffset,
                            KRaftVersion.fromFeatureLevel(
                                ((KRaftVersionRecord) record.message()).kRaftVersion()
                            )
                        );
                    }
                    break;

                default:
                    // Skip the rest of the control records
                    break;
            }
            ++offsetDelta;
        }
    }
Returns the finalized kraft version at a given offset.

@param offset the offset (inclusive)
@return the finalized kraft version if one exist, otherwise 0
raft/src/main/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachine.java