akalash commented on a change in pull request #16885:
URL: https://github.com/apache/flink/pull/16885#discussion_r694678887



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
##########
@@ -875,7 +875,8 @@ public final void cleanUp(Throwable throwable) throws 
Exception {
 
         failing = !canceled && (!(throwable instanceof CancelTaskException));
 
-        Exception suppressedException = 
runAndSuppressThrowable(this::cancelTask, null);
+        Exception suppressedException =
+                throwable == null ? null : 
runAndSuppressThrowable(this::cancelTask, null);

Review comment:
       If you pass `supressedException` to `runAndSuppressThrowable` you can 
avoid catching exceptions when you call `cleanUp`. I mean it will be possible 
to transform code `restoreAndInvoke` from:
   ```
   try {
              ....
   } catch (Throwable throwable) {
       try {
           runWithSystemExitMonitoring(() -> finalInvokable.cleanUp(throwable));
       } catch (Throwable cleanUpThrowable) {
           throwable.addSuppressed(cleanUpThrowable);
       }
       throw throwable;
   }
   ```
   to 
   ```
   try {
              ....
   } catch (Throwable throwable) {
       runWithSystemExitMonitoring(() -> finalInvokable.cleanUp(throwable));
   }
   ```




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