getExecution() not available on DelegateTask interface, what to use instead?

Hello, I’m working on upgrade from Activiti version 5.2.2 into Flowable 6.7.2. There was quite a lot occurances in the system of such mechanism:

class AnyClass implements TaskListener{

@Override
public void notify(DelegateTask delegateTask){
DelegateExecution execution = delegateTask.getExecution();

// many actions performed on the execution…
}
}

Unfortunately DelegateTask interface has been modified quite a long time ago, and there is not getExecution() method available anymore, I could find getExecutionId() instead, but I’m not sure what would be the correct way of capturing the Execution or preferable DelegateExecution, don’t know which Service will provide such with the same capabilities like that older implementation had. Could you please advise on that? I need to be careful with that changes to leave the system stable after the upgrade. Thanks!

Hi Michael,
Yes, lots has changes from when Activiti 5.2 was released.
I’m not sure exactly what “many actions performed on the execution” really entails but there may be easier ways to achieve your goals now.
That said, you can get the execution from the RuntimeService using an execution query:

    RuntimeService rs = ProcessEngines.getDefaultProcessEngine().getRuntimeService();
    Execution ex = rs.createExecutionQuery().executionId(task.getExecutionId()).singleResult();

Again, not sure if refactoring is better or not, but at least this should move you forward.

Thank you, that definitely helps!