flowable / flowable/flowable-engine

DMN engine bug: `RepositoryServiceImpl.getDecisionsForProcessDefinition` throw an exception when the same decision key is used by multiple tenants

Aperta
#3,606 1 commento 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**
`RepositoryServiceImpl.getDecisionsForProcessDefinition` throws an exception when there are multiple decisions with the same key and version.

Example stack trace:

```
root org.flowable.common.engine.api.FlowableException: Query return 3 results instead of max 1
root at org.flowable.common.engine.impl.query.AbstractQuery.executeSingleResult(AbstractQuery.java:184)
root at org.flowable.common.engine.impl.query.AbstractQuery.execute(AbstractQuery.java:164)
root at org.flowable.dmn.engine.impl.interceptor.DmnCommandInvoker$1.run(DmnCommandInvoker.java:45)
root at org.flowable.dmn.engine.impl.interceptor.DmnCommandInvoker.executeOperations(DmnCommandInvoker.java:62)
root at org.flowable.dmn.engine.impl.interceptor.DmnCommandInvoker.execute(DmnCommandInvoker.java:49)
root at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
root at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:105)
root at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
root at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
root at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
root at org.flowable.common.engine.impl.query.AbstractQuery.singleResult(AbstractQuery.java:105)
root at org.flowable.engine.impl.cmd.GetDecisionsForProcessDefinitionCmd.addDecisionToCollection(GetDecisionsForProcessDefinitionCmd.java:115)
root at org.flowable.engine.impl.cmd.GetDecisionsForProcessDefinitionCmd.getDecisionsFromModel(GetDecisionsForProcessDefinitionCmd.java:86)
root at org.flowable.engine.impl.cmd.GetDecisionsForProcessDefinitionCmd.execute(GetDecisionsForProcessDefinitionCmd.java:69)
root at org.flowable.engine.impl.cmd.GetDecisionsForProcessDefinitionCmd.execute(GetDecisionsForProcessDefinitionCmd.java:1)
root at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:67)
root at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:140)
root at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:114)
root at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:72)
root at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26)
root at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
root at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:105)
root at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
root at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
root at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
root at org.flowable.engine.impl.RepositoryServiceImpl.getDecisionsForProcessDefinition(RepositoryServiceImpl.java:373)

```

This [method here](https://github.com/flowable/flowable-engine/blob/2ae0f8974074b031df609dea2bc942426660d326/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetDecisionsForProcessDefinitionCmd.java#L99) has multiple problems:

1. it should **not** by default look for decisions in the same deployment as the process
2. it should only look for decisions which belong to the same tenant as the process; alternatively it should look for the same decision key in the default tenant decisions in case "fallback to default tenant" is enabled.

**Expected behavior**
Return the latest version of decisions referenced by the process. When the "fallback to default tenant" option is enabled, return the latest version of the decision with the same key from the default tenant.

**Additional context**
Version: v.6.7.2.32.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetDecisionsForProcessDefinitionCmd.java, in particolare da getDecisionsFromModel e addDecisionToCollection, quindi segui RepositoryServiceImpl.getDecisionsForProcessDefinition. Riproduci il caso con più tenant e chiavi duplicate e verifica che venga restituita la decisione più recente dello stesso tenant, con fallback al tenant predefinito solo quando abilitato.

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.