flowable / flowable/flowable-engine

Changing assignee in TaskListener is ok in runtime but out-of-date in history

Aperta
#3,199 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
9.5k
Fork
2.9k
Merge medio
7h 8m
PR unite (30g)
2

Descrizione

**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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Non sono indicati file del repository né test. Inizia riproducendo il problema con il Java TaskListener e l’evento di assegnazione forniti, quindi segui come setAssignee aggiorna le entità di runtime e history, verificando anche gli endpoint delle attività runtime/history e le tabelle act_ru_task/act_hi_taskinst. Il lavoro è completato quando il nuovo assignee è coerente in runtime, history e nelle viste delle attività dell’amministrazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.