davsclaus opened a new pull request, #29190: URL: https://github.com/apache/camel/pull/29190
_Claude Code on behalf of Claus Ibsen (davsclaus)_ [CAMEL-26596](https://issues.apache.org/jira/browse/CAMEL-26596) ## Problem `FileConsumer.doStart()` called `super.doStart()` twice: once inside the `try` block, and again after the `finally`. The second call was left over from CAMEL-21782 (4.11), which moved `autoCreate` into `doStart()` and wrapped the parent call in a `try`/`finally`. Because `startScheduler` is back on by then, the whole `ScheduledPollConsumer.doStart()` ran again: `scheduler.onInit()`, `scheduler.scheduleTask()`, starting the scheduler service and `startScheduler()`. The schedulers that ship with Camel (default, Quartz, Spring) ignore the second call, so most users don't notice. A custom `ScheduledPollConsumerScheduler` whose `scheduleTask`/`startScheduler` are not idempotent registers the task twice and polls twice. ## Fix - Remove the second `super.doStart()`. The first call already does all of the parent's startup work, and the `finally` block starts the scheduler. `AbstractSftpConsumer` already has this shape. The other `GenericFileConsumer` subclasses (FTP, SFTP, SMB, Azure Files) don't have the bug. - `FileConsumerCustomSchedulerTest` was loosened in CAMEL-21782 to `counter == 2`, and later to `counter <= 2` ("camel may run the scheduler once during startup so the value is +1"). That extra run was this bug. The test now asserts that `scheduleTask`, `startScheduler` and the poll each happen exactly once. Without the fix it fails with `expected: <1> but was: <2>`. ## Testing - `FileConsumerCustomSchedulerTest` fails without the fix and passes with it. - All 481 tests in `org.apache.camel.component.file.**` in camel-core pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0128ThHB3iQdrvSRLVBGRrdP -- 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]
