@Test
    public void testHandleExceptionThrowingAnException() throws Exception {
        try (KafkaEventQueue queue = new KafkaEventQueue(Time.SYSTEM, logContext, "testHandleExceptionThrowingAnException")) {
            CompletableFuture<Void> initialFuture = new CompletableFuture<>();
            queue.append(() -> initialFuture.get());
            AtomicInteger counter = new AtomicInteger(0);
            queue.append(new EventQueue.Event() {
                @Override
                public void run() {
                    counter.incrementAndGet();
                    throw new IllegalStateException("First exception");
                }

                @Override
                public void handleException(Throwable e) {
                    if (e instanceof IllegalStateException) {
                        counter.incrementAndGet();
                        throw new RuntimeException("Second exception");
                    }
                }
            });
            queue.append(() -> counter.incrementAndGet());
            assertEquals(3, queue.size());
            initialFuture.complete(null);
            TestUtils.waitForCondition(() -> counter.get() == 3,
                    "Failed to see all events execute as planned.");
        }
    }
Test that we continue handling events after Event#handleException itself throws an exception.
server-common/src/test/java/org/apache/kafka/queue/KafkaEventQueueTest.java