allthingssecurity opened a new pull request, #30843: URL: https://github.com/apache/camel/pull/30843
# Description [CAMEL-27459](https://issues.apache.org/jira/browse/CAMEL-27459) The polling consumer (without `useKclConsumers`) lists the shards of the stream with a `ShardMonitor` task scheduled with `scheduleAtFixedRate` every `shardMonitorInterval`. `ShardMonitor.run` caught only `Exception`. An `Error` of one run (`NoClassDefFoundError`, `ExceptionInInitializerError`, `AssertionError`) ended the scheduled task: the executor keeps the error in the `ScheduledFuture`, which nothing reads, so nothing was logged and the task never ran again. The consumer went on reading the shards of the last list, so the shards created by a later split or merge were never read, and the consumer stayed UP until the route was restarted. `ScheduledPollConsumer.run` logs such an error for the same reason ("the thread pool wont re-schedule"), and CAMEL-26906 fixed the same case in `TimerListenerManager`. Change, in `Kinesis2Consumer`, the same pattern as CAMEL-26906: - an `Error` of a monitor run is logged at WARN ("Error getting latest shard list", with the stack trace, as the existing WARN for an `Exception`), and the task runs again at the next interval; - a `VirtualMachineError` (such as an `OutOfMemoryError`) is thrown on as before, which ends the task, as in CAMEL-26906; it is now logged at ERROR first, with the stream name and that the shards of a later split or merge are not listed until the consumer is restarted. The consumer goes on reading the shards it knows, as before: failing its polls would stop the reading of every shard because of a monitor that only matters at the next reshard; - `ShardMonitor` is package-private so that the test runs it. No upgrade guide entry: nothing changes for a consumer whose monitor works, and nothing is to be done by users. Not changed here: - a `ListShards` call of the async client (`listShards(request).get()`) waits without a timeout. The SDK's own read and acquire timeouts apply, so a real call normally completes or fails. - after a stop and start of the same consumer instance, a monitor run of the previous start that is still in progress can publish its older list after the new monitor's list; the next run corrects it. A route restart creates a new consumer. - a consumer whose `ListShards` fails from the start is reported ready and UP while it reads nothing; that has its own ticket and pull request. Tests, new `KinesisConsumerShardMonitorErrorTest` (2, mocked `KinesisClient`, no sleep): - `anErrorOfOneRunDoesNotStopTheMonitor`: the scheduled monitor (every 10 ms) gets one shard, then a `NoClassDefFoundError`, then the shards of a split; the consumer's list must get the two child shards (Awaitility, at most 10 s), and the next poll reads them from `TRIM_HORIZON`; - `aVirtualMachineErrorStopsOnlyTheMonitor`: a monitor run (run by the test) that gets an `OutOfMemoryError` throws it on; the next poll still reads the known shard, with error counter 0 and readiness UP; after a stop and start the new monitor lists the shards of a split. Without the change the first test fails (the list never gets the children within 10 s); the second passes on main too, as the `VirtualMachineError` was already thrown on there (it pins that the consumer keeps reading). The new WARN and ERROR lines show in the test log; the module has no log-capture pattern, so they are not asserted. With it the camel-aws2-kinesis unit tests pass (66 run, plus the 1000 seeds of the DST test, 0 failures), and the new class passes 20 of 20 runs. The ITs need LocalStack and were not run locally (CI runs them). The local offline build used AWS SDK 2.57.11 (as on main). The change merges cleanly with the branch of the sibling ticket, and the merged consumer passes both new test classes and the consumer tests 5 of 5 runs. Backport: candidate for the 4.x LTS lines that have the shard monitor; the change is local to `Kinesis2Consumer` and does not change behaviour while the monitor works. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27459](https://issues.apache.org/jira/browse/CAMEL-27459). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-aws2-kinesis and the core modules with the formatter and import-sort plugins and ran the camel-aws2-kinesis unit tests. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
