allthingssecurity opened a new pull request, #31016: URL: https://github.com/apache/camel/pull/31016
# Description [CAMEL-27634](https://issues.apache.org/jira/browse/CAMEL-27634) The ticket lists three problems of camel-cron that came up while the option descriptions were written for CAMEL-23832 (#30972, merged). I checked each one against main, which has #30972. All three are fixed here. Fixed: 1. **A seven-part schedule failed to start with the spring cron service.** `CronComponent` accepts five to seven parts, but `CamelSpringCronService.createEndpoint()` passed a seven-part schedule (with a year) as it was, and Spring's `CronExpression.parse()` takes exactly six fields (checked in the spring-context 7.1.0 of main). I checked on main that the endpoint is created and the route then fails to start with `IllegalArgumentException: Cron expression must consist of 6 fields (found 7 in "0 0/2 * * * MON-FRI 2030")`. The spring cron service now refuses such a schedule when the endpoint is created, with a message that names the spring cron service and the year, as it already does for the five-part schedules it cannot convert. The `schedule` option and the doc page now say that camel-spring does not support the year. camel-quartz does not change. 2. **A cronService name that matched no bean was ignored.** `CronHelper.resolveCamelCronService()` fell back to the cron service found on the classpath without a word, so a typo, or a bean that was not bound, selected another implementation. The component now fails to start with an `IllegalArgumentException` that names the value, and the id of the cron service found on the classpath, if any. 3. **cronService did not match the id of a CamelCronService.** `cronService=quartz` worked only with a bean named `quartz`, and with camel-quartz and camel-spring both on the classpath the classpath order picked the implementation. When no bean has the name, `CronHelper` now loads the factory key `cron/cron-service-<name>`, which camel-quartz (`cron-service-quartz`) and camel-spring (`cron-service-spring`) now provide next to their `cron-service` file, and else accepts the cron service of the classpath whose `getId()` is the name. A bean with the name still wins, and without `cronService` nothing changes. The behaviour changes of points 1 and 2 are in the 4.24 upgrade guide. A route that sets `cronService` to a name that matches no bean and no cron service id now fails to start; before, it ran with the cron service of the classpath. #30972 is merged, and this branch is based on it. This PR changes two of its texts: - the `cronService` option: `"The name of the CamelCronService bean in the registry to use, when more than one is bound. If not set, the only CamelCronService in the registry is used. If the registry has none, the one that a module on the classpath provides is used, such as camel-quartz or camel-spring."` It now also says that the value can be the id of a cron service (quartz or spring), and that the component fails to start when neither matches. - the `schedule` option, which said that the year is optional, now also says that camel-spring does not support it. Not changed: camel-kamelet-main maps only the `cron/cron-service` key to camel-quartz in its known dependencies, and I did not add the new `cron/cron-service-quartz` and `cron/cron-service-spring` keys there. I did not test `cronService` with Camel JBang. Tests: - `CronServiceByIdTest` (camel-cron, new): `cronService=other` selects the cron service of the test file `cron/cron-service-other`; `cronService=dummy` matches the id of the cron service of the classpath; `cronService=nosuch` fails with a message that names it and the id dummy; a bean with the name wins over the id. Against the main sources 2 of the 4 fail (the default service is used for other, and nosuch does not fail); the other two pass, as they work on main too. - `CamelSpringCronServiceTest` (camel-spring, new): a seven-part schedule fails the endpoint with a message about the spring cron service and the year; a six-part schedule creates a `SpringCronEndpoint`; `cronService=spring` selects the spring cron service. Against the main sources the first fails (the endpoint is created); the other two pass. - `QuartzCronServiceByIdTest` (camel-quartz, new): `cronService=quartz` selects the quartz cron service without a bean of that name. It passes on main too, where the fallback picks the only cron service; it covers the new `cron-service-quartz` file. Results (offline, test phase, unit tests only; the three modules were built together in a local aggregator that is not part of this PR, so that camel-quartz and camel-spring use the changed camel-cron): camel-cron 11 tests, camel-quartz 139 tests, camel-spring 8 tests, 0 failures, 0 errors, 0 skipped. The new test classes, with `CronLoaderTest`, passed 5 runs in a row. Generated files: `cron.json` of the component and its catalog copy, the catalog copy of the doc page, `CronEndpointBuilderFactory` of the endpoint DSL and `CronComponentBuilderFactory` of the component DSL (the descriptions of `schedule` and `cronService`). camel-spring was built and tested offline with Spring 7.0.9 (main uses 7.1.0). # 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-27634](https://issues.apache.org/jira/browse/CAMEL-27634). # 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-cron, camel-quartz and camel-spring and ran their unit tests, and committed the regenerated component JSON. The catalog copies of the JSON and of the doc page are copies of the component files (they were identical on main), and the endpoint and component DSL were regenerated from the JSON with the generate-endpoint-dsl and generate-component-dsl goals of camel-package-maven-plugin, as an offline build of those modules was not possible here. 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]
