Issue #3621217: Restore the ECA token bag by value, so an eca_event node gives back what it found under the names it borrows

The eca_event task snapshots the five token-bag names it owns before dispatching its custom event and restores them afterwards. The snapshot was taken with getTokenData(), which answers ECA's DataTransferObject for the name rather than the value in it, and ECA reuses that same object on every later write to the name. So the task saved the container, wrote its own value into that very container, and then restored the container over itself: nothing was given back.

The snapshot now reads the value and clones it when it is a DataTransferObject. Map::__clone() deep-clones the properties, so a later write to the name cannot reach the snapshot, and an entity or a structured value is given back as itself rather than flattened to an ID or a Yaml blob.

The consequence is a name that already held a value when the node ran. Within one Orchestra cascade every name is clear, because ECA stores an empty string as NULL and so the restore-to-empty of the preceding node really does unset it; the losses are the value a caller holds under the node's configured outcome token, and, when a reacting model synchronously drives another eca_event node, the outer node's own token and instance ids.

Two new kernel tests cover it. The first seeds the configured outcome token, answers the event with something else, and asserts the node both recorded the answer and gave the seeded value back. It fails against the container snapshot with 'approved' where 'the caller owns this' was expected.

The second is the nested case the snapshot exists for: the outer node's model answers and then starts a second synchronous workflow inline, so the inner eca_event node writes the same bag names inside the outer node's dispatch. It asserts the inner run really advanced, that the outer node routed on its own answer rather than the inner one, and that the model still read the outer instance ID afterwards.

A first attempt at the test ran three eca_event nodes back to back and passed against the unfixed code, which is what established that the cascade is not where this bites.

Edited by Frank Mably

Merge request reports

Loading
Loading