Finding Job instance associated with a user task in a given process instance

After running some more experiments, I have come to a bizarre conclusion for this mystery.
I found that when more than one process instances are running, Management Service API JobQuery can find all previous jobs except for the current process instance. That means,

  • for 3 process instances, timer jobs queried in the third process instance delegate are for the 2 previous process instancs,
  • for 2 process instances, timer job found is for 1 previous process instance and so on.
    When there is only one instance, there is no previous process instance and therefore, total job count is 0. Due to this, jobs for current querying process instance are always zero.

Please read my detailed analysis on github as it’s too long to produce here.

As of 29.01.2020, Camunda v7.13.0-SNAPSHOT, this is a definite bug in JobQuery implementation in Java Management Service API. I am opening a new thread indicating this bug . I hope I can attract attention of Camunda developers.