question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClassCastException when calling ExecutionTime.forCron() for RebootCron

See original GitHub issue

Bug 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:

  1. ) Return a Execution time instance that does only return empty optionals for next & last execution time.
  2. ) 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

#520

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jmrozaneccommented, Jul 30, 2022

@J0B10 cron-utils version 9.2.0 was released with this functionality and the fixes for the issues above. Thank you again! 😄 🚀

1reaction
jmrozaneccommented, Jul 30, 2022

@J0B10 we implemented the fixes! 😎 A new release will follow soon 🚀 Thank you for contributing to cron-utils! 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found