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

L option for Quartz Parser is not working #23

Closed
gokhanoner opened this issue Jun 15, 2015 · 3 comments
Closed

L option for Quartz Parser is not working #23

gokhanoner opened this issue Jun 15, 2015 · 3 comments
Assignees

Comments

@gokhanoner
Copy link

Hi

When I try t use the Quartz Parser for below expression, I got error

expression:

0 0/10 22 L * ?

Error message

Exception in thread "main" java.lang.IllegalArgumentException: Number 0 out of range [1,31]
at com.cronutils.model.field.constraint.FieldConstraints.validateInRange(FieldConstraints.java:111)
at com.cronutils.model.field.expression.FieldExpression.validate(FieldExpression.java:48)
at com.cronutils.model.field.expression.On.<init>(On.java:52)
at com.cronutils.parser.field.FieldParser.parseOn(FieldParser.java:136)
at com.cronutils.parser.field.FieldParser.parse(FieldParser.java:51)
at com.cronutils.parser.field.CronParserField.parse(CronParserField.java:68)
at com.cronutils.parser.CronParser.parse(CronParser.java:88)

I believe the issue is FieldParser/parseOn method. It set 0 for this fileds IntegerFieldValue on On class and it raises exception because DAY_OF_MONTH should be between 1-31

    if (exp.contains("L")) {
        specialChar = new SpecialCharFieldValue(SpecialChar.L);
        exp = exp.replace("L", "");
        if ("".equals(exp)) {
            expression = "0";//to avoid a NumberFormatException
        } else {
            expression = exp;
        }
    }
@jmrozanec
Copy link
Owner

@gokhanoner good catch! Thank you for reporting this and for the insight where may the issue be!

@jmrozanec jmrozanec added the bug label Jun 16, 2015
@jmrozanec
Copy link
Owner

Test case for this issue:

/**
 * Issue #23: we should support L in DoM
 */
@Test
public void testLSupportedInDoM() throws Exception {
    parser.parse("0 0/10 22 L * ?");
}

@jmrozanec
Copy link
Owner

@gokhanoner issue fixed! Thank you for reporting!

@jmrozanec jmrozanec self-assigned this Jun 16, 2015
@jmrozanec jmrozanec added the done label Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants