[ 
https://issues.apache.org/jira/browse/CAMEL-27634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27634:
--------------------------------
    Fix Version/s: 4.24.0
                       (was: 4.25.0)

> camel-cron: 7-part schedule fails with spring; cronService ignores unknown 
> names and ids
> ----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27634
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27634
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Claus Ibsen
>            Assignee: shashank
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while improving the option descriptions of camel-cron for CAMEL-23832 
> (PR https://github.com/apache/camel/pull/30972).
> These are separate problems of the component; the descriptions PR only 
> documents the current behavior.
> h4. 1. A seven-part schedule (with a year) fails to start with the spring 
> cron service
> {{CronComponent.validate()}} accepts a schedule of five to seven parts, and 
> the doc page gives the seven-part example {{0 0/2 * * * MON-FRI 2030}}. 
> {{CamelSpringCronService.createEndpoint()}} converts only a five-part 
> schedule and passes a seven-part one unchanged as {{scheduler.cron}}. 
> {{SpringScheduledPollConsumerScheduler.doStart()}} then calls {{new 
> CronTrigger(...)}}, and Spring's {{CronExpression.parse()}} (spring-context 
> 7.1.0) accepts exactly 6 fields.
> The route fails when it starts, with {{IllegalArgumentException: Cron 
> expression must consist of 6 fields (found 7 in ...)}}. With camel-quartz the 
> same schedule works.
> Proposed change: reject a seven-part schedule in 
> {{CamelSpringCronService.createEndpoint()}} with a message that names the 
> cron service, as is done there for five-part schedules it cannot convert. The 
> doc page should also say that the year works only with camel-quartz.
> h4. 2. A cronService name that matches no bean is ignored without a warning
> {{CronHelper.resolveCamelCronService()}} looks up {{cronService}} with 
> {{CamelContextHelper.lookup(context, name, CamelCronService.class)}}. When no 
> bean has that name, it falls back to 
> {{ResolverHelper.resolveBootstrapService(context, "cron/cron-service", 
> ...)}}, which returns the service found on the classpath.
> A typo in {{cronService}}, or a bean that is not bound, makes the component 
> use another implementation, and nothing is logged.
> Proposed change: when {{cronService}} is set and no matching service is 
> found, fail with an error that names the value.
> h4. 3. cronService does not match the id of a CamelCronService
> {{CamelCronService}} extends {{HasId}}, and the two implementations return 
> the ids {{quartz}} ({{CamelQuartzCronService}}) and {{spring}} 
> ({{CamelSpringCronService}}). {{CronHelper.resolveCamelCronService()}} never 
> reads {{getId()}}: {{cronService=quartz}} works only if a bean is bound in 
> the registry under the name {{quartz}}.
> If camel-quartz and camel-spring are both on the classpath and no bean is 
> bound, the factory finder loads the first 
> {{META-INF/services/org/apache/camel/cron/cron-service}} found, so the 
> classpath order picks the implementation, and {{cronService}} cannot choose 
> between them.
> Proposed change: when no bean has the name, also match {{cronService}} 
> against the ids of the services, for example by loading 
> {{cron/cron-service-<id>}} (or by checking {{getId()}} of the resolved 
> service).
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to