ClassCastException when calling ExecutionTime.forCron() for RebootCron
See original GitHub issueBug description
cron-utils Version: https://github.com/jmrozanec/cron-utils/commit/307990d14686a89560c768b876259532694b9ae4
When calling ExecutionTime.forCron(cron)
on a Reboot schedule we get the following ClassCastException:
java.lang.ClassCastException: class com.cronutils.model.RebootCron cannot be cast to class
com.cronutils.model.CompositeCron (com.cronutils.model.RebootCron and com.cronutils.model.CompositeCron are in unnamed
module of loader 'app')
at com.cronutils.model.time.ExecutionTime.forCron(ExecutionTime.java:76)
at org.betonquest.betonquest.api.schedule.CronSchedule.<init>(CronSchedule.java:91)
at org.betonquest.betonquest.api.schedule.CronRebootScheduleTest$1.<init>(CronRebootScheduleTest.java:21)
at org.betonquest.betonquest.api.schedule.CronRebootScheduleTest.createSchedule(CronRebootScheduleTest.java:21)
This exception is not thelling the library user what went wrong here.
Intended behaviour
I would assume either one of the following two behaviours, as clearly there is no way for the model to tell a next execution time for the reboot cron:
- ) Return a Execution time instance that does only return empty optionals for next & last execution time.
- ) Throw a checked exception that is more descriptive of the actual issue.
I personally prefer the 2nd option as I think it works better with existing code.
Related issues
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
ClassCastException when calling ExecutionTime.forCron() for ...
ClassCastException when calling ExecutionTime.forCron() for RebootCron. This issue has been created since 2022-07-30. Bug description.
Read more >reboot nickname support · Issue #520 · jmrozanec/cron-utils
J0B10 mentioned this issue on Jul 30. ClassCastException when calling ExecutionTime.forCron() for RebootCron #528.
Read more >cron-utils - githubmemory
asString() output for cron containing weekdays. andysenn ... ClassCastException when calling ExecutionTime.forCron() for RebootCron. jmrozanec.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@J0B10 cron-utils version 9.2.0 was released with this functionality and the fixes for the issues above. Thank you again! 😄 🚀
@J0B10 we implemented the fixes! 😎 A new release will follow soon 🚀 Thank you for contributing to cron-utils! 😄