gharris1727 commented on code in PR #12920: URL: https://github.com/apache/kafka/pull/12920#discussion_r1035223460
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTaskTest.java: ########## @@ -687,7 +687,26 @@ public void testCommitFlushCallbackFailure() throws Exception { callback.onCompletion(failure, null); return null; }); - testCommitFailure(failure); + testCommitFailure(failure, false); + } + + @Test + public void testCommitFlushAsyncCallbackFailure() throws Exception { + Exception failure = new RecordTooLargeException(); + when(offsetWriter.willFlush()).thenReturn(true); + when(offsetWriter.beginFlush()).thenReturn(true); + // doFlush delegates it's callback to the producer, + // which delays completing the callback until commitTransaction + AtomicReference<Callback<Void>> callback = new AtomicReference<>(); + when(offsetWriter.doFlush(any())).thenAnswer(invocation -> { + callback.set(invocation.getArgument(0)); + return null; + }); + doAnswer(invocation -> { + callback.get().onCompletion(failure, null); + throw failure; Review Comment: this makes a lot of sense, thanks for catching this! -- 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