Given:
- Process with an non-interrupting conditional EventSubProcess
When:
- Process instance is created with variables which triggers this event process
Then:
- History for all given variables are not written.
Observation:
It seems that the Listener which writes the history for the variable events is not called.
This is because ExecutionEntity#isAutoFireHistoryEvents returns false in ExecutionEntity#getVariableInstanceLifecycleListeners.
Please see the attached unit test and process model to reproduce this bug.
Example:
RuntimeService runtimeService = processEngineRule.getRuntimeService(); Map<String, Object> variables = new HashMap<>(); variables.put("startTimer", 1L); variables.put("duration", "PT2S"); final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("sample", "0815", variables); TaskService taskService = processEngineRule.getTaskService(); Task task = taskService.createTaskQuery().singleResult(); if (task != null) { assertEquals("init process", task.getName()); taskService.complete(task.getId()); } assertEquals(processEngineRule .getHistoryService() .createHistoricVariableInstanceQuery() .count(), 2L); // fails
Workaround:
RuntimeService runtimeService = processEngineRule.getRuntimeService(); Map<String, Object> variables = new HashMap<>(); // variables.put("startTimer", 1L); variables.put("duration", "PT2S"); final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("sample", "0815", variables); runtimeService.setVariable(processInstance.getProcessInstanceId(), "startTimer", 1L); TaskService taskService = processEngineRule.getTaskService(); Task task = taskService.createTaskQuery().singleResult(); if (task != null) { assertEquals("init process", task.getName()); taskService.complete(task.getId()); } assertEquals(processEngineRule .getHistoryService() .createHistoricVariableInstanceQuery() .count(), 2L);