RocMarshal commented on code in PR #21999:
URL: https://github.com/apache/flink/pull/21999#discussion_r1117058961


##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java:
##########
@@ -1103,35 +1143,41 @@ private void 
testFailToConfirmCheckpointMessage(Consumer<StreamTask<?, ?>> consu
      * finished.
      */
     @Test
-    public void testCheckpointFailueOnClosedOperator() throws Throwable {
+    void testCheckpointFailueOnClosedOperator() throws Exception {
         ClosingOperator<Integer> operator = new ClosingOperator<>();
         StreamTaskMailboxTestHarnessBuilder<Integer> builder =
                 new StreamTaskMailboxTestHarnessBuilder<>(
                                 OneInputStreamTask::new, 
BasicTypeInfo.INT_TYPE_INFO)
                         .addInput(BasicTypeInfo.INT_TYPE_INFO);
         try (StreamTaskMailboxTestHarness<Integer> harness =
                 
builder.setupOutputForSingletonOperatorChain(operator).build()) {
-            // keeps the mailbox from suspending
-            harness.setAutoProcess(false);
-            harness.processElement(new StreamRecord<>(1));
-
-            harness.streamTask.operatorChain.finishOperators(
-                    harness.streamTask.getActionExecutor(), StopMode.DRAIN);
-            harness.streamTask.operatorChain.closeAllOperators();
-            assertTrue(ClosingOperator.closed.get());
-
-            harness.streamTask.triggerCheckpointOnBarrier(
-                    new CheckpointMetaData(1, 0),
-                    CheckpointOptions.forCheckpointWithDefaultLocation(),
-                    new CheckpointMetricsBuilder());
-        } catch (Exception ex) {
-            ExceptionUtils.assertThrowableWithMessage(
-                    ex, "OperatorChain and Task should never be closed at this 
point");
+            assertThatThrownBy(
+                            () -> {
+                                // keeps the mailbox from suspending
+                                harness.setAutoProcess(false);
+                                harness.processElement(new StreamRecord<>(1));
+
+                                
harness.streamTask.operatorChain.finishOperators(
+                                        
harness.streamTask.getActionExecutor(), StopMode.DRAIN);
+                                
harness.streamTask.operatorChain.closeAllOperators();
+                                
assertThat(ClosingOperator.closed.get()).isTrue();
+
+                                harness.streamTask.triggerCheckpointOnBarrier(
+                                        new CheckpointMetaData(1, 0),
+                                        
CheckpointOptions.forCheckpointWithDefaultLocation(),
+                                        new CheckpointMetricsBuilder());
+                            })
+                    .satisfies(
+                            (Consumer<Throwable>)
+                                    throwable ->
+                                            
ExceptionUtils.assertThrowableWithMessage(
+                                                    throwable,
+                                                    "OperatorChain and Task 
should never be closed at this point"));

Review Comment:
   I can understand what you mean. I have a try on it with failed result, So, 
what about  keeping the current lines, please let me know what's your opinion.
   
   <img width="1106" alt="image" 
src="https://user-images.githubusercontent.com/64569824/221199128-34ed3b53-1106-4b1f-b77a-5e7124fbd20c.png";>
   



-- 
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]

Reply via email to