Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException if cron expression is null [SPR-15683] #20242

spring-projects-issues opened this issue Jun 20, 2017 · 1 comment

NullPointerException if cron expression is null [SPR-15683] #20242

spring-projects-issues opened this issue Jun 20, 2017 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jun 20, 2017

Antoine M opened SPR-15683 and commented

While playing around with scheduled tasks and cron triggers, I realized that when you feed a null cron expression to a CronTrigger then a wild NullPointerException is thrown instead of an IllegalArgumentException with a message.

When you pass a null cron expression to the constructor of CronTrigger, it creates a CronSequenceGenerator instance which calls the parse() method from its constructor.
Inside this method the cron expression is first tokenized by StringUtils.tokenizeToStringArray() (which will return null if the cron expression is null) and put into the fields variable. Then, if the content of fields is considered invalid (null or not having the right number of elements), an IllegalArgumentException is thrown.
But as we are using fields.count's value to create the message of the exception, we get a NullPointerException (with no message) instead when fields is null.

The changes proposed in the pull request #1345 let the parse() method throw an IllegalArgumentException with a message when fields is null.

Affects: 3.2.18, 4.3.9, 5.0 RC2

Issue Links:

  • #20163 Cron expression validation method in CronSequenceGenerator improved ("duplicates")

Referenced from: pull request #1345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.