private boolean assign(EpochEntry entry) {
        if (entry.epoch < 0 || entry.startOffset < 0) {
            throw new IllegalArgumentException("Received invalid partition leader epoch entry " + entry);
        }

        // Check whether the append is needed before acquiring the write lock
        // in order to avoid contention with readers in the common case
        if (!isUpdateNeeded(entry)) return false;

        lock.writeLock().lock();
        try {
            if (isUpdateNeeded(entry)) {
                maybeTruncateNonMonotonicEntries(entry);
                epochs.put(entry.epoch, entry);
                return true;
            } else {
                return false;
            }
        } finally {
            lock.writeLock().unlock();
        }
    }
Assigns the supplied Leader Epoch to the supplied Offset
Once the epoch is assigned it cannot be reassigned
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java