Skip to content

Commit

Permalink
[refactor][runtime] Moved the INITIALIZING transition under cleanUp t…
Browse files Browse the repository at this point in the history
…ry-catch block
  • Loading branch information
akalash committed Sep 8, 2021
1 parent d726c03 commit 8542b78
Showing 1 changed file with 12 additions and 12 deletions.
Expand Up @@ -751,18 +751,6 @@ private void doRun() {
// by the time we switched to running.
this.invokable = invokable;

// switch to the INITIALIZING state, if that fails, we have been canceled/failed in the
// meantime
if (!transitionState(ExecutionState.DEPLOYING, ExecutionState.INITIALIZING)) {
throw new CancelTaskException();
}

taskManagerActions.updateTaskExecutionState(
new TaskExecutionState(executionId, ExecutionState.INITIALIZING));

// make sure the user code classloader is accessible thread-locally
executingThread.setContextClassLoader(userCodeClassLoader.asClassLoader());

restoreAndInvoke(invokable);

// make sure, we enter the catch block if the task leaves the invoke() method due
Expand Down Expand Up @@ -924,6 +912,18 @@ else if (transitionState(current, ExecutionState.FAILED, t)) {

private void restoreAndInvoke(TaskInvokable finalInvokable) throws Exception {
try {
// switch to the INITIALIZING state, if that fails, we have been canceled/failed in the
// meantime
if (!transitionState(ExecutionState.DEPLOYING, ExecutionState.INITIALIZING)) {
throw new CancelTaskException();
}

taskManagerActions.updateTaskExecutionState(
new TaskExecutionState(executionId, ExecutionState.INITIALIZING));

// make sure the user code classloader is accessible thread-locally
executingThread.setContextClassLoader(userCodeClassLoader.asClassLoader());

runWithSystemExitMonitoring(finalInvokable::restore);

if (!transitionState(ExecutionState.INITIALIZING, ExecutionState.RUNNING)) {
Expand Down

0 comments on commit 8542b78

Please sign in to comment.