flowable / flowable/flowable-engine
Changing assignee in TaskListener is ok in runtime but out-of-date in history
- Vorherrschende Sprache
- Java
- Sterne
- 9.5k
- Forks
- 2.9k
- Ø Merge
- 7 Std. 8 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
**Describe the bug**
I wrote a custom Java TaskListener that updates the assignee of a user task in certain cases (using `delegateTask.setAssignee(...)`). After execution of the listener (at the point that the task can be performed) I can see in the task runtime (`GET runtime/tasks/{taskId}`) that the assignee has changed, but in the task history (`GET history/historic-task-instances/{taskId}`) it hasn't. This corresponds with what is in the database: table `act_ru_task` holds the correct value while `act_hi_taskinst` holds the old value. Also in the admin interface, you see the old assignee in the task list and the tasks of a process instance, but if you go to the task detail page, the updated value is shown.
I've tried to attach the task listener both on the "assignment" and the "create" event of of the task with same result.
**Expected behavior**
I guess task runtime and history should be in synch at all times, like it is for variables or other entity types. Persisting the assignee to act_hi_taskinst as well as act_ru_task after the TaskListener execution should fix this problem.
**Code**
This is the code of my TaskListener bean:
```java
@Override
public void notify(DelegateTask task) {
String newAssignee = (String) task.getVariable("assignee_override");
if (StringUtils.hasText(newAssignee)) {
String previousAssignee = task.getAssignee();
task.setAssignee(newAssignee);
LOG.info("Changed assignee of task " + task.getId() + " of type " +
task.getTaskDefinitionKey() + " from '" + previousAssignee + "' to '" +
newAssignee + "'.");
}
}
```
It is installed in BPMN like this:
```xml
```
**Additional context**
Tested in Flowable v6.7.2 and v6.5.0
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Es werden keine Repository-Dateien oder Tests genannt. Beginnen Sie damit, das Problem mit dem bereitgestellten Java TaskListener und dem Assignment-Ereignis zu reproduzieren. Verfolgen Sie anschließend, wie setAssignee die Laufzeit- und Verlaufseinträge aktualisiert, und prüfen Sie dabei die Runtime-/History-Task-Endpunkte sowie die Tabellen act_ru_task/act_hi_taskinst. Als abgeschlossen gilt die Aufgabe, wenn der neue Assignee in Runtime, History und den Admin-Aufgabenansichten konsistent ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100