1996fanrui commented on code in PR #21999:
URL: https://github.com/apache/flink/pull/21999#discussion_r1115402015
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskITCase.java:
##########
@@ -110,6 +118,42 @@ public void testFailInEndOfConstructor() throws Exception {
.build(EXECUTOR_RESOURCE.getExecutor()));
}
+ @Test
+ public void
streamTaskAsyncExceptionHandlerHandleExceptionInInitializingDuration()
+ throws Exception {
+ MockEnvironment mockEnvironment = MockEnvironment.builder().build();
+ RuntimeException expectedException = new RuntimeException("RUNTIME
EXCEPTION");
+
+
mockEnvironment.setExpectedExternalFailureCause(AsynchronousException.class);
+ final String expectedErrorMessage = "EXPECTED_ERROR MESSAGE";
+
+ NoOpStreamTask noOpStreamTask =
+ new NoOpStreamTask(mockEnvironment) {
+ @Override
+ protected void init() throws Exception {
+ super.init();
+ CompletableFuture.runAsync(
+ () -> {
+ assertFalse(this.isRunning());
+ assertTrue(this.isInitializing());
+ this.handleAsyncException(
+ expectedErrorMessage,
expectedException);
+ });
+ }
Review Comment:
Flink test doesn't recommend using the `sleep`, you can use the
`CompletableFuture future = new CompletableFuture()`.
Main thread call the `future.wait()`, and async thread calls the
`future.complete(null)` after some operators done.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]