soarez commented on code in PR #14903: URL: https://github.com/apache/kafka/pull/14903#discussion_r1417143188
########## server-common/src/main/java/org/apache/kafka/queue/KafkaEventQueue.java: ########## @@ -513,4 +513,28 @@ public void close() throws InterruptedException { eventHandlerThread.join(); log.info("closed event queue."); } + + /** + * Useful for unit tests, where we need to speed the clock up until + * deferred events are ready to run. + */ + public Object pendingDeferredEvent() { + lock.lock(); + try { + if (eventHandler.head.next != eventHandler.head) { + return null; + } + Map.Entry<Long, EventContext> entry = eventHandler.deadlineMap.firstEntry(); + if (entry == null) { + return null; + } + EventContext eventContext = entry.getValue(); + if (eventContext.insertionType == EventInsertionType.DEFERRED) { Review Comment: That is incorrect. Events of any type can end up in `deadlineMap` as long as they have a deadline specified. The notion of deadline here is a bit confusing. A deadline for events of type `DEFERRED` is the time after which the event should run. For events of other types, the deadline is the time after which `TimeoutException` should be delivered if the event hasn't run yet. So we want to ignore events that are not of type `DEFERRED`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org