I found a bug in the treatment of HistoricDetail (VariableUpdate type) in later versions to 5.16.4.
It is occours when I store variables in a UserTask with "processEngine.getTaskService().setVariable()", without completing the UserTask.
If I store variables with:
processEngine.getTaskService().setVariable(taskId, "var_1", "this is a save var");
With activiti 18.104.22.168. In the database. ACT_HI_DETAIL table: the "ACT_INST_ID_" field is null.
With activiti 5.16.4 the field has the correct value (the ID of the activity).
I attached two JUnit tests to prove it: activiti-unit-test-hcovardetail_5.16.4_OK.zip and activiti-unit-test-hcovardetail_22.214.171.124_FAIL.zip