@Test
    public void testInterruptedWithEmptyQueue() throws Exception {
        CompletableFuture<Void> cleanupFuture = new CompletableFuture<>();
        try (KafkaEventQueue queue = new KafkaEventQueue(Time.SYSTEM, logContext, "testInterruptedWithEmptyQueue", () -> cleanupFuture.complete(null))) {
            CompletableFuture<Thread> queueThread = new CompletableFuture<>();
            queue.append(() -> queueThread.complete(Thread.currentThread()));
            TestUtils.retryOnExceptionWithTimeout(30000, () -> assertEquals(0, queue.size()));
            queueThread.get().interrupt();
            cleanupFuture.get();
            ExceptionTrapperEvent ieTrapper = new ExceptionTrapperEvent();
            queue.append(ieTrapper);
            assertEquals(InterruptedException.class, ieTrapper.exception.get().getClass());
            queue.close();
            ExceptionTrapperEvent reTrapper = new ExceptionTrapperEvent();
            queue.append(reTrapper);
            assertEquals(RejectedExecutionException.class, reTrapper.exception.get().getClass());
        }
    }
Test that we continue handling events after Event#handleException itself throws an exception.
server-common/src/test/java/org/apache/kafka/queue/KafkaEventQueueTest.java