Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-9426

No tasks returned when userId == null, exlOwner !=null and groups !=null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.46.0.Final
    • None
    • KieServer
    • None
    • False
    • False
    • NEW
    • NEW
    • Undefined
    • ---
    • ---
    • 2020 Week 40-42 (from Sep 28), 2020 Week 43-45 (from Okt 19)

    Description

      we have found a bug in query API, it's rather a edge case.

      Here is how to reproduce:

      • Design a human task with Groups attribute filled and ExcludedOwnerId set as well

      Something like this:
      https://github.com/DuncanDoyle/jbpm-four-eyes-process/blob/master/four-eyes-principle/src/main/resources/four-eyes-process.bpmn2

      Now try to look for this task using following API:

      https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client/UserTaskServicesClient.java#L127

      Now, we are looking for tasks only by Groups, so we don't care about User, and therefore we are setting UserId to null and only passing Groups, it looks like this:
      tasks = userTaskServicesClient.findTasksAssignedAsPotentialOwner(null,Arrays.asList("SII_CHECKER"),ACTIVE_TASK_STATUSES,0,100);

      So for this particular combination, when task has group as a potential owner, excluded owner is not null, and we are searching for this task with userid == null NO results are returned.

      This is because of how SQL queries are written:
      https://github.com/kiegroup/jbpm/blob/c398d626110d983d7af3c2e95c7e5228cbb34d32/jbpm-human-task/jbpm-human-task-jpa/src/main/resources/META-INF/Taskorm.xml#L205

      that particular line will be translated to this:

      and null not in
      (
      select exclOwner.entity_id
      from
      PeopleAssignments_ExclOwners exlOwner
      where
      task.id = exlOwner.task_id
      )
      
      and null not in
      (
      "someExcludedOwner"
      )
      

      which is false, because of SQL three valued logic -> this is causing no results.

      If I rewrite it to this:

      and '' not in
      (
      select exclOwner.entity_id
      from
      PeopleAssignments_ExclOwners exlOwner
      where
      task.id = exlOwner.task_id
      )
      

      i.e. I replaced null with empty string, it is evaluated as true, and it does return results - this is one of the possible solution engineering could try..

      [NOTE ENG]
      affects as well
      TasksAssignedAsPotentialOwnerWithGroups
      TasksAssignedAsPotentialOwnerByStatusWithGroups
      TasksAssignedAsPotentialOwnerStatusByExpirationDate
      TasksAssignedAsPotentialOwnerStatusByExpirationDateOptional
      SubTasksAssignedAsPotentialOwner
      QuickTasksAssignedAsPotentialOwnerWithGroupsByStatus
      QuickTasksAssignedAsPotentialOwnerStatusByExpirationDateOptional
      QuickTasksAssignedAsPotentialOwnerStatusByExpirationDate
      NewTasksAssignedAsPotentialOwner
      NewTasksAssignedAsPotentialOwnerByExpirationDateOptional
      NewTasksAssignedAsPotentialOwnerByExpirationDate

      Attachments

        Issue Links

          Activity

            People

              elguardian@gmail.com Enrique González Martínez (Inactive)
              elguardian@gmail.com Enrique González Martínez (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: