Affects: spring-context:5.3.4


Hi...

IMHO

org.springframework.scheduling.support.CronExpression.parse(
   org.springframework.scheduling.annotation.Scheduled.CRON_DISABLED);

should not throw java.lang.IllegalArgumentException.

Comment From: poutsma

Why? CronExpression represents a cron expression, whereas Scheduled.CRON_DISABLED represents an annotation value used to disable cron expressions altogether.

Comment From: schapsl

Because the annotation value of cron in org.springframework.scheduling.annotation.Scheduled a.k.a @Scheduled accepts a cron expression as well as Scheduled.CRON_DISABLED

So basically Scheduled.CRON_DISABLED is a valid cron expression in the context of @Scheduled. Not accepting it in org.springframework.scheduling.support.CronExpression.parse is inconsistent imho.

My use case is to allow @Scheduled( cron = ${myProperty}), where it should be possible to turn of the trigger. I'm quite happy Scheduled.CRON_DISABLED exists. But i also like use CronExpression.parse in a different location.

Comment From: poutsma

So basically Scheduled.CRON_DISABLED is a valid cron expression in the context of @Scheduled.

Indeed, it is a valid value in that context/module, because of way we use annotations to configure scheduling support. But CronExpression is a low-level component that knows nothing about annotations. And from the perspective of CronExpression, CRON_DISABLED (i.e. -) is simply not a valid expression.