flowable-engine icon indicating copy to clipboard operation
flowable-engine copied to clipboard

TaskService.getIdentityLinksForTask(taskId)

Open maratkalibek opened this issue 3 years ago • 1 comments

Describe the bug

TaskService.getIdentityLInksForTask(taskId) is duplicating IdentityLink in results. Looks like same IdentityLink added to list twice.

Expected behavior

TaskService.getIdentityLInksForTask(taskId) should not duplicate IdentityLink in results.

Code

image

Additional context

https://github.com/flowable/flowable-engine/blob/main/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java#L247-L270

Here, getCandidates method returns set, but getIdentityLinks returns map. So duplicates are removed for getCandidates method.

maratkalibek avatar Sep 18 '22 16:09 maratkalibek

Can you describe more details? How to reproduce this bug? Which version of flowable? And anything else.

pandaapo avatar Sep 19 '22 01:09 pandaapo

I've had a similar issue too. This problem is easy to reproduce.

Flowable Engine Version As of the latest 6.7.2-release, this issue has not been resolved

<dependency>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-engine</artifactId>
    <version>6.7.2</version>
</dependency>

How to reproduce Just follow the Getting Started.

Here is my sample project zip package: flowable-example.zip

Set the breakpoint to org.flowable.engine.impl.util.IdentityLinkUtil as shown taskEntity getIdentityLinks

Then you see the problem issue

kendoziyu avatar Nov 29 '22 08:11 kendoziyu

Quickly checked this: This is a runtime behavior inconsistency on the TaskEntity, which seems to happen only during process execution. Problem is gone, when the task is loaded again, or the taskService.getIdentityLinksForTask method is used.

Root cause of the problem is, that taskEntityImpl#getIdentityLinks is not a simple getter like expected, but it initializes identity links too.

The identityLink gets initially created (and persisted) in https://github.com/flowable/flowable-engine/blob/97277a611624b83cba83d55b1d712332d31bb7f5/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java#L375

And then twice here (once because the unexpected side-effect in taskEntity.getIdentityLinks()):

https://github.com/flowable/flowable-engine/blob/982be7e47facf17bb779571ba663bdf8f86947a3/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/util/IdentityLinkUtil.java#L90

The TaskEntityImpl getter: https://github.com/flowable/flowable-engine/blob/02b22f89af90516a921fcc921ea0bee21d72f8c5/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java#L261-L262

In general that is not so nice, because the getter does not even work, when it is called outside of an execution (with a NPE).

arthware avatar Nov 29 '22 12:11 arthware