Federico Mariani created CAMEL-24145:
----------------------------------------
Summary: camel-saga: InMemorySagaCoordinator
compensate()/complete() return already-completed futures - finalization
failures never propagate
Key: CAMEL-24145
URL: https://issues.apache.org/jira/browse/CAMEL-24145
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: Federico Mariani
h3. Problem
{{InMemorySagaCoordinator.compensate()}} and {{complete()}}
(core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java:122-155)
kick off {{doCompensate()}}/{{doComplete()}} - an async chain running on the
saga executor - and then unconditionally:
{code:java}
return CompletableFuture.completedFuture(null);
{code}
h3. Consequence
* The error handling written around these calls is dead code with the in-memory
service: {{SagaProcessor.handleSagaCompletion}} does
{{coordinator.complete(exchange).whenComplete((done, ex) -> ifNotException(ex,
...))}} (SagaProcessor.java:89-101), and {{SagaProducer}}
({{saga:complete}}/{{saga:compensate}}) does the same - but {{ex}} can never be
non-null and the future is already done. The exchange finishes before any
completion/compensation endpoint has been invoked even once, and a completion
endpoint that fails all retries never fails or flags anything beyond a WARN log.
* Semantics diverge from camel-lra, where {{complete()}}/{{compensate()}}
return the coordinator HTTP call future and a rejected close/cancel fails the
exchange.
* Callers of a saga route get their reply before the completion callbacks ran -
an observable ordering difference vs LRA and a source of test flakiness.
h3. Suggested fix
Deliberate asynchrony is defensible for the compensation *retries* (5 x 5s by
default must not block the failing exchange), but the returned future should at
least reflect the outcome of the first finalization attempt (or the state
transition validation), and the async contract of {{CamelSagaCoordinator}}
should be documented so both implementations agree.
Found during a broader Saga EIP / camel-lra code review (July 2026).
_Claude Code on behalf of Croway_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)