[
https://issues.apache.org/jira/browse/CAMEL-24082?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrea Cosentino resolved CAMEL-24082.
--------------------------------------
Resolution: Fixed
> camel-aws-cloudtrail: consumer loses events (static cursor, no pagination,
> time-window skip)
> --------------------------------------------------------------------------------------------
>
> Key: CAMEL-24082
> URL: https://issues.apache.org/jira/browse/CAMEL-24082
> Project: Camel
> Issue Type: Bug
> Components: camel-aws
> Reporter: Andrea Cosentino
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.14.9, 4.18.4, 4.22.0
>
>
> The camel-aws-cloudtrail consumer can silently drop CloudTrail events:
> 1. *Shared static cursor* — {{CloudtrailConsumer.lastTime}} is declared
> {{private static Instant lastTime}}. Two cloudtrail routes in the same JVM
> (different eventSource/region) overwrite each other's cursor, and the value
> leaks across consumer restarts.
> 2. *No pagination* — {{poll()}} issues a single {{lookupEvents(...)}} call
> and never follows {{response.nextToken()}}. Combined with the default
> {{maxResults = 1}}, at most one event per poll is ever retrieved; the rest of
> the window is discarded.
> 3. *Time-window skip* — the cursor is advanced to the newest returned event's
> time and the next request uses {{startTime(lastTime.plusMillis(1000))}}.
> Events that occur within that 1s window (or share the newest event's
> timestamp) after the newest processed event are skipped forever, and there is
> no event-id de-duplication.
> Code references (main): CloudtrailConsumer.java lines 36 (static field),
> 44-67 (poll), and CloudtrailConfiguration.java line 52 (maxResults default 1).
> Fix direction:
> - Make {{lastTime}} an instance field, initialized to the consumer start time
> so polling tails from startup rather than replaying history.
> - Paginate the lookup by following {{nextToken()}} until the window is
> drained.
> - Advance the cursor using the newest event time as an inclusive
> {{startTime}} and de-duplicate the boundary events by {{eventId}} (bounded to
> the newest-timestamp second) instead of the lossy +1000ms skip.
> - Raise the default {{maxResults}} to a sane page size (AWS LookupEvents
> allows up to 50); with pagination this becomes a page-size knob, not a
> per-poll cap.
> This changes first-poll behavior (it no longer emits the single most-recent
> historical event) and the default maxResults, so an upgrade-guide note is
> required. The module currently ships no unit tests; tests will be added with
> the fix. Present on camel-4.18.x and camel-4.14.x — backport to both.
> Found during an agent-assisted audit of the AWS components; verified by
> reading the cited code.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)