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.

Exception swallowed in "AndFieldValueGenerator"

See original GitHub issue

In AndFieldValueGenerator, in the function

protected List<Integer> generateCandidatesNotIncludingIntervalExtremes(int start, int end)

there is a try/catch which just logs the exception and returns an empty list.

Catched expected exception while generating candidates
com.cronutils.model.time.generator.NoSuchValueException: null
	at com.cronutils.model.time.generator.AndFieldValueGenerator.generateNextValue(AndFieldValueGenerator.java:52)
	at com.cronutils.model.time.generator.AndFieldValueGenerator.generateCandidatesNotIncludingIntervalExtremes(AndFieldValueGenerator.java:84)
	at com.cronutils.model.time.generator.FieldValueGenerator.generateCandidates(FieldValueGenerator.java:61)
	at com.cronutils.model.time.ExecutionTimeBuilder.forHoursMatching(ExecutionTimeBuilder.java:64)
	at com.cronutils.model.time.ExecutionTime.forCron(ExecutionTime.java:53)

So I have a situation where a client generates cron expressions interactively using the parser, and expressions which are “valid” then generate completely unexpected results when used with the ExecutionTime class.

The exception is printed, but there is no way to guard against this behaviour because the exception is not propagated.

An example expression is 0 0 0-07,17-0 ? * SAT which is parsed as every hour between 0 and 7 and every hour between 17 and 0 at Saturday day.

If this is expression is not usable, it should not be accepted by the parser. If that’s too hard, at least when an ExecutionTime is created using a Cron which it can’t use, an exception should be generated so it is possible to validate against that, and keep junk out of the system.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jmrozaneccommented, Apr 27, 2020

@jamescosford glad to hear that! That things moved on and the exception no longer appears, as well that you sent a PR 😄 Thanks! We will merge soon. Best!

0reactions
jmrozaneccommented, Oct 12, 2020

@IndeedSi thank you for the insight!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceptions Rule Set | Detekt
Exceptions should not be swallowed. This rule reports all instances where exceptions are caught and not correctly passed (e.g. as a cause) into...
Read more >
c# - Task swallows the exception thrown - Stack Overflow
The exception is not swallowed; it's just that it doesn't occur on the thread that executes the try/catch block, but on the separate...
Read more >
cron-utils - githubmemory
Exception swallowed in "AndFieldValueGenerator " · Previous Next. Make software development more efficient, Also welcome to join our telegram.
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