DelegateVariableMapping::mapOutputVariables gets called on exception inside a call activity

I have a process, that calls another (child) process using the call activity element.
The call activity element is configured with a DelegateVariableMapping class to extract some data out of the child process.

Inside a child process I have a service task element with an end event listener on it.
When I try to finish the task, the event listener throws an exception - this is expected, my custom data validation fails. What is not expected is that DelegateVariableMapping::mapOutputVariables gets called. The documentation Delegation Code | docs.camunda.org states:

The mapOutputVariables method is called after the call activity was executed, to map the output variables.

As per my understanding, the call activity is still executing, it’s not finished - I can even try to finish its service task again, but again this leads to the DelegateVariableMapping::mapOutputVariables being called.

The questions are:

  1. Is this expected? What am I missing in my understanding of DelegateVariableMapping and call activities?
  2. How to differentiate the actual end of the call activity inside the DelegateVariableMapping::mapOutputVariables call?

For the question #2 I have come up with a solution: I downcast the second argument, VariableScope, to an ExecutionEntity, and check if it .isEnded() before doing any mapping. Is this solution acceptable, will it always work?