-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Environment (Required on creation)
Any.
Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)
A client is experiencing an issue where his start timer event with a Cron expression is creating infinite jobs instead of the ones that match the expression. The reason behind it seems to be an bug in the CronExpression getTimeAfter algorithm, only for expressions containing "L-X"
meaning X
days before the end of the month. For example 0 0 12 L-27 * ?
which means 27 days before the end of each month at 12:00:00
.
The CronExpression class is interpreting the expression correctly, but when getting the "after time", meaning the next date that matches the expression, it's not working and returning the date for the current month even if it's in the past.
Steps to reproduce (Required on creation)
- Deploy a process definition with a start event timer with a Cron expression containing the L-X syntax, for example
0 0 12 L-27 * ?
. - The X should be greater than the remaining days in the current month to reproduce the behavior.
Observed Behavior (Required on creation)
The computed execution date will be in the past, and this will trigger the execution multiple times instead of once.
Expected behavior (Required on creation)
The computed execution should always be in the future. If the target date has already passed for the current month, then it should be created once for the following month.
Root Cause (Required on prioritization)
There's a bug in the CronExpression getTimeAfter algorithm.
Solution Ideas
- Either fix the bug by taking inspiration of the latest release of Quartz Library. If we follow this approach, take this bug into account (and it's correction).
- Or directly use their library as a dependency.
Hints
Created a pull request that contains:
- The expected behavior in the test additions.
- A POC for the CronExpression class.
Links
Breakdown
Pull Requests
- test(engine): add test for cron expressions #5285
- chore(engine): switch to cron-utils #5288
- chore(docs): switch from quartz to spring cron expressions camunda-docs-manual#1803
- chore(update): adjust cron expression paragraph camunda-docs-manual#1821
Dev2QA handover
- Does this ticket need a QA test and the testing goals are not clear from the description? Add a Dev2QA handover comment