CAMEL-24141: Aggregate EIP - guard background tasks against exceptions#24821
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Review: CAMEL-24141 — Aggregate EIP: guard background tasks against exceptions
What works well
Correct fix for a well-known Java scheduling pitfall. When a Runnable submitted to ScheduledExecutorService throws an unchecked exception, the executor silently stops scheduling future runs. Wrapping both AggregationIntervalTask.run() and RecoverTask.run() in try/catch(Exception) with a LOG.warn is the standard defensive pattern — and is already used by DefaultTimeoutMap.purgeTask() in this codebase.
Null-safe aggregateCompletionCounter(). Adding the early return when completedBy is null prevents an NPE in the switch statement for recovered exchanges that may not have the CamelAggregatedCompletedBy property set. Clean and minimal.
Correct catch placement in RecoverTask. The catch(Exception) sits between the recovery logic and the finally block that clears recoveryInProgress and inProgressCompleteExchangesForRecoveryTask, so cleanup still runs on exception.
Checklist
| Item | Status |
|---|---|
| Tests | ✅ 177 existing aggregator tests cover normal paths |
| Docs / Upgrade guide | N/A (internal defensive hardening) |
| Commit convention | ✅ CAMEL-24141: <description> |
| Public API / backward compat | ✅ No API changes |
| Security | N/A |
| CI | ⏳ Pending |
Note: This PR includes the CAMEL-24140 commit on the same branch — the AggregateProcessor changes are the only new code for this PR.
Static analysis: semgrep (0 findings).
Clean, minimal, and correct. No concerns.
Reviewed with Claude Code on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
oscerd
left a comment
There was a problem hiding this comment.
The guards themselves look correct — wrapping AggregationIntervalTask.run() and RecoverTask.run() in try/catch(Exception) + LOG.warn keeps a single background-task exception from killing the scheduler, the inner lock/finally unlock is preserved (no lock leak), and RecoverTask's catch sits before the finally that clears recoveryInProgress, matching the existing DefaultTimeoutMap.purgeTask() convention. The null-safe aggregateCompletionCounter early-return is a reasonable NPE guard too.
One thing before merge: the CAMEL-24141 change (scheduler survives after a background task throws) has no dedicated test — the only test added here (MulticastUseOriginalShareUnitOfWorkTest) belongs to the stacked CAMEL-24140. A small test that makes an interval/recover task throw and asserts the scheduler keeps running would lock in the actual fix. (Also note this PR is stacked with #24820's reifier change — worth confirming the merge order.)
Reviewed with Claude Code on behalf of Andrea Cosentino. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 544 tested, 29 compile-only — current: 544 all testedMaveniverse Scalpel detected 573 affected modules (current approach: 544).
|
…s that kill scheduled executor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
ad1a76b to
750c2c0
Compare
Summary
try/catch(Exception)guard toAggregationIntervalTask.run()andRecoverTask.run()so that a transient exception (e.g. repository hiccup) does not permanently cancel the scheduled background taskaggregateCompletionCounter()null-safe to avoid NPE whenCamelAggregatedCompletedByproperty is absent on recovered exchangesDefaultTimeoutMap.purgeTask()which catches and logs exceptions to keep the scheduled executor aliveTest plan
org.apache.camel.processor.aggregator.*Test)Claude Code on behalf of davsclaus
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com