hook that is guaranteed to be called, even when a task throws an exception which will cause afterTaskExecution to not be called.
As an example you can clear the security context here if you set it in the beforeTaskExecution hook.
Will be not null if the task failed with an exception.
The stage for the task execution.
The task that is being handled.
Will be null if the task failed with an exception.