After long and cumbersome search we think, we have nailed two issues with camunda which (added together) lead to the Exception from the original question.
Camunda uses
equals
on serialized objects (represented by byte-arrays) to determine, whether process variables have to be written back to the database. This even happens when variables are only read and not set. Asequals
is defined by pointer-identity on arrays, a serializabled-Object is never determined "equal" if it has been serialized more than once. We have found, that a singleruntimeService.setVariable()
leads to four db-updates at the time ofcompleteTask()
(One for setVariable itself, the other three for various camunda-internal validation actions). We think this is a bug and will file a bug report to camunda.Obviously there are two ways to set variables. One way is to use
runtimeService.setVariable()
, the other is to usedelegateTask/delegateExecution.setVariable()
. There is some flaw when using both ways at the same time. While we cannot simplify our setup to a simple unit-test, we have identified several components which have to be involved for the Exception to occur:
2.1 We are using a TaskListener
to set up some context-variables at the start of Tasks this task-listener used runtimeService.setVariable()
instead of delegateTask.setVariable()
. After we changed that, the Exception vanished.
2.2 We used (and still use) runtimeService.setVariable()
during Task-Execution. After we switched to completeTask(Variables)
and omitted the runtimeService.setVariable()
calls, the Exception vanished as well. However, this isn't a permanent solution as we have to store process variables during task execution.
2.3 The exception occured only in combination when process variables where read or written by the delegate<X>.getVariable()
way (either by our code or implicitly in the camunda implementation of juel-parsing with gateways and serviceTasks or completeTask(HashMap)
)
Thanks a lot for all your input.