Repository: apache/kafka
File: server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java (Java)

Code before:
    private final Consumer<Long> idleTimeCallback;


    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix
    ) {
        this(time, logContext, threadNamePrefix, VoidEvent.INSTANCE, Optional.empty());
    }

    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix,
        Event cleanupEvent
    ) {
        this(time, logContext, threadNamePrefix, cleanupEvent, Optional.empty());
    }

    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix,
        Event cleanupEvent,
        Optional<Consumer<Long>> idleTimeCallback
    ) {
        this.time = time;
        this.cleanupEvent = Objects.requireNonNull(cleanupEvent);
        this.lock = new ReentrantLock();
        this.log = logContext.logger(KafkaEventQueue.class);
        this.eventHandler = new EventHandler();
        this.eventHandlerThread = new KafkaThread(threadNamePrefix + EVENT_HANDLER_THREAD_SUFFIX,
            this.eventHandler, false);
        this.shuttingDown = false;
        this.interrupted = false;
        this.idleTimeCallback = idleTimeCallback.orElse(__ -> { });
        this.eventHandlerThread.start();
    }

    public Time time() {
        return time;
    }

    @Override
    public void enqueue(EventInsertionType insertionType,
                        String tag,
                        UnaryOperator<OptionalLong> deadlineNsCalculator,
                        Event event) {
        EventContext eventContext = new EventContext(event, insertionType, tag);
        Exception e = eventHandler.enqueue(eventContext, deadlineNsCalculator);

Review comment (suggestion):
out of curiosity, have you consider using `Consumer<Long>` instead? the other constructor could pass `__ -> { }`.

Code after:
    private final Consumer<Long> idleTimeCallback;


    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix
    ) {
        this(time, logContext, threadNamePrefix, VoidEvent.INSTANCE, __ -> { });
    }

    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix,
        Event cleanupEvent
    ) {
        this(time, logContext, threadNamePrefix, cleanupEvent, __ -> { });
    }

    public KafkaEventQueue(
        Time time,
        LogContext logContext,
        String threadNamePrefix,
        Event cleanupEvent,
        Consumer<Long> idleTimeCallback
    ) {
        this.time = time;
        this.cleanupEvent = Objects.requireNonNull(cleanupEvent);
        this.lock = new ReentrantLock();
        this.log = logContext.logger(KafkaEventQueue.class);
        this.eventHandler = new EventHandler();
        this.eventHandlerThread = new KafkaThread(threadNamePrefix + EVENT_HANDLER_THREAD_SUFFIX,
            this.eventHandler, false);
        this.shuttingDown = false;
        this.interrupted = false;
        this.idleTimeCallback = Objects.requireNonNull(idleTimeCallback);
        this.eventHandlerThread.start();
    }

    public Time time() {
        return time;
    }

    @Override
    public void enqueue(EventInsertionType insertionType,
                        String tag,
                        UnaryOperator<OptionalLong> deadlineNsCalculator,
                        Event event) {
        EventContext eventContext = new EventContext(event, insertionType, tag);
        Exception e = eventHandler.enqueue(eventContext, deadlineNsCalculator);