lindong28 commented on a change in pull request #15161: URL: https://github.com/apache/flink/pull/15161#discussion_r600194416
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContextTest.java ########## @@ -182,6 +191,44 @@ public void testSnapshotAndRestore() throws Exception { restoredTracker.assignmentsByCheckpointId()); } + @Test + public void testCallableInterruptedDuringShutdownDoNotFailJob() throws InterruptedException { + AtomicReference<Throwable> expectedError = new AtomicReference<>(null); + + ManuallyTriggeredScheduledExecutorService manualWorkerExecutor = + new ManuallyTriggeredScheduledExecutorService(); + ManuallyTriggeredScheduledExecutorService manualCoordinatorExecutor = + new ManuallyTriggeredScheduledExecutorService(); + + SourceCoordinatorContext<MockSourceSplit> testingContext = + new SourceCoordinatorContext<>( + manualCoordinatorExecutor, + manualWorkerExecutor, + new SourceCoordinatorProvider.CoordinatorExecutorThreadFactory( + TEST_OPERATOR_ID.toHexString(), getClass().getClassLoader()), + operatorCoordinatorContext, + new MockSourceSplitSerializer(), + splitSplitAssignmentTracker); + + testingContext.callAsync( + () -> { + throw new InterruptedException(); + }, + (ignored, e) -> { + if (e != null) { + expectedError.set(e); + throw new RuntimeException(e); + } + }); + + manualWorkerExecutor.triggerAll(); Review comment: It is needed here. `callAsync(...)` indirectly calls `manualWorkerExecutor.execute(...)`, which enqueues the runnable into an internal queue (in `ManuallyTriggeredScheduledExecutorService`) without actually executing the runnable. We need to call `manualWorkerExecutor.triggerAll()` to execute the runnable. I verified that, if we remove `manualWorkerExecutor.triggerAll()`, the test would fail due to `assertTrue(expectedError.get() instanceof InterruptedException)` failure. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org