public class

CronExpressionFixer

extends Object
java.lang.Object
   ↳ com.atlassian.jira.upgrade.tasks.util.CronExpressionFixer

Class Overview

Utility for repairing a cron expression that is failing to parse under Caesium but was apparently previously allowed by Quartz.

There are certain error cases that Quartz ignored but that Caesium enforces. This tool attempts to identify these problems and repair the cron expression. The type of repair done is intended to preserve the spirit of the original expression as closely as possible. The following specific cases are handled:

ProblemExampleRepairedComment
Invalid step interval 0 0/60 * * * ? 0 0 * * * ? Quartz ignores the invalid interval, so throwing it away has the same result
Multiple values with W 0 0 0 1W,15W * ? 0 0 0 1,15 * ? Quartz either ignores all of the W flags or only processes the first value, depending on which came first. Throwing away the W flags is the easiest way to come as close as we can to what they asked for.
Illegal characters 0 0 0 ? * *? 0 0 0 ? * * Quartz ignores the stray ? at the end. This repair code will try just deleting the illegal character.

If the cron expression parser returns an error that is not covered by any of these cases, or if after 5 attempts to fix the expression it still has problems, we give up.

Summary

Nested Classes
class CronExpressionFixer.Result Represents the result of an attempt to repair a cron expression. 
Public Methods
@Nonnull static CronExpressionFixer.Result repairCronExpression(String cronExpression)
Attempts to repair a possibly broken cron expression.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

@Nonnull public static CronExpressionFixer.Result repairCronExpression (String cronExpression)

Attempts to repair a possibly broken cron expression.

Parameters
cronExpression the cron expression to repair
Returns
  • the result of the attempted repair