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



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java
##########
@@ -762,17 +762,21 @@ private void doRun() {
             
executingThread.setContextClassLoader(userCodeClassLoader.asClassLoader());
 
             AbstractInvokable finalInvokable = invokable;
-            runWithSystemExitMonitoring(finalInvokable::restore);
+            try {
+                runWithSystemExitMonitoring(finalInvokable::restore);
 
-            if (!transitionState(ExecutionState.INITIALIZING, 
ExecutionState.RUNNING)) {
-                throw new CancelTaskException();
-            }
+                if (!transitionState(ExecutionState.INITIALIZING, 
ExecutionState.RUNNING)) {
+                    throw new CancelTaskException();
+                }
 
-            // notify everyone that we switched to running
-            taskManagerActions.updateTaskExecutionState(
-                    new TaskExecutionState(executionId, 
ExecutionState.RUNNING));
+                // notify everyone that we switched to running
+                taskManagerActions.updateTaskExecutionState(
+                        new TaskExecutionState(executionId, 
ExecutionState.RUNNING));
 
-            runWithSystemExitMonitoring(finalInvokable::invoke);
+                runWithSystemExitMonitoring(finalInvokable::invoke);
+            } finally {
+                runWithSystemExitMonitoring(finalInvokable::cleanUp);
+            }

Review comment:
       I've extracted the interfaces in 9c217799fb4aaeb5bee3fcb1f1408f3842c66b54
   and used them more widely in 7665ff55b614b610c6a41a708e7e9d4a8c736fa7.
   
   WDYT of this change?
   
   The commits change about 20 files but I'm still not sure if it should be 
included into 1.14.
   
   cc: @pnowojski




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to