AnsweredAssumed Answered

Inconsistent procvar behaviour

Question asked by marcus1 on Sep 19, 2011
Latest reply on Sep 24, 2011 by marcus1
I found some strange behaviour regarding the storing and updating of process variables. Suppose we have the following process:

Process A:
Service 1 -> Task 1 -> Service 2 -> Task 2 -> Service 3

Service 1 creates a new process variable:

Book book = new Book("12345");
execution.setVariable("book", book);
Service 2 changes a property:

Book book = execution.getVariable("book");
book.setTitle("Activiti in Action");
Service 3 prints the content of the process variable:

Book book = execution.getVariable("book");
System.out.println("book=" + book);
Result: book=Book [isbn=12345, title=Activiti in Action]

This is as (I) expected. However, now we remove Task 1. Lets see what happens.

Process B:
Service 1 -> Service 2 -> Task 2 -> Service 3

Result: book=Book [isbn=12345, title=null]

This is strange… the variable is not updated whereas it was in the first process.

It seems that changes to process variables are only persisted if there is a waitstate between the creation and the update of the var.

Also, when debugging this issue I noticed that VariableType.serialize is called twice every time setVariable (or rather createVariableLocal) is called: once by VariableInstanceEntity.createAndInsert and once by VariableScopeImpl.setVariableInstanceValue.

I've tried to attach a patch with a testcase, but this results in the error "The extension diff is not allowed"…