Skip to content

CronExpression cannot parse combination of step values #26313

@m15o

Description

@m15o

CronExpression throws IllegalArgumentException when you use following expression:

new CronExpression.parse("* 5,10-30/2 * * * *")
java.lang.IllegalArgumentException: For input string: "5,10" '5,10-30/2' in cron expression "* 5,10-30/2 * * * *"	at org.springframework.scheduling.support.CronExpression.parse(CronExpression.java:201)	at org.jetbrains.kotlin.idea.scratch.generated.ScratchFileRunnerGenerated$ScratchFileRunnerGenerated.generated_get_instance_res0(tmp.kt:11)	at org.jetbrains.kotlin.idea.scratch.generated.ScratchFileRunnerGenerated.main(tmp.kt:20) Caused by: java.lang.IllegalArgumentException: For input string: "5,10" '5,10-30/2'	at org.springframework.scheduling.support.BitsCronField.parseField(BitsCronField.java:150)	at org.springframework.scheduling.support.BitsCronField.parseMinutes(BitsCronField.java:75)	at org.springframework.scheduling.support.CronField.parseMinutes(CronField.java:66)	at org.springframework.scheduling.support.CronExpression.parse(CronExpression.java:191)	... 2 more Caused by: java.lang.NumberFormatException: For input string: "5,10"	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)	at java.base/java.lang.Integer.parseInt(Integer.java:652)	at java.base/java.lang.Integer.parseInt(Integer.java:770)	at org.springframework.scheduling.support.BitsCronField.parseRange(BitsCronField.java:165)	at org.springframework.scheduling.support.BitsCronField.parseField(BitsCronField.java:135)	... 5 more 

CronSequenceGenerator is able to parse the same expression.

new CronSequenceGenerator("* 5,10-30/2 * * * *")

Affects: 5.3

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions