Skip to content

Improve validation of intervals?Β #120

@SimonGustavsson

Description

@SimonGustavsson

Hello πŸ‘‹

Creating a RecurrenceRule with an interval that is just large enough causes IllegalArgumentException.

It looks like this happens here where the interval is multiple with 7 which causes it to overflow to a negative number which the calendar rightly rejects.

I do think lib-recur is doing the right thing rejecting this (it's a silly interval after all), but the exception is very unexpected.

Could/should this be validated a little earlier on and surfaced in a more obvious way perhaps?

Repro steps:

    @Test
    public void itOverflows() throws InvalidRecurrenceRuleException {
        RecurrenceRule rule = new RecurrenceRule("FREQ=WEEKLY;INTERVAL=1000000000", RfcMode.RFC5545_STRICT);
        RecurrenceRuleIterator iterator =
             rule.iterator(1578406277000L, TimeZone.getTimeZone("America/New_York"));
    }

Exception:

java.lang.IllegalArgumentException: n must be >=0
	at org.dmfs.rfc5545.calendarmetrics.NoLeapMonthCalendarMetrics.nextDay(NoLeapMonthCalendarMetrics.java:226)
	at org.dmfs.rfc5545.recur.Freq$3.next(Freq.java:74)
	at org.dmfs.rfc5545.recur.FreqIterator.next(FreqIterator.java:98)
	at org.dmfs.rfc5545.recur.SanityFilter.next(SanityFilter.java:92)
	at org.dmfs.rfc5545.recur.RecurrenceRuleIterator.fetchNextInstance(RecurrenceRuleIterator.java:95)
	at org.dmfs.rfc5545.recur.RecurrenceRuleIterator.<init>(RecurrenceRuleIterator.java:89)
	at org.dmfs.rfc5545.recur.RecurrenceRule.iterator(RecurrenceRule.java:2216)
	at org.dmfs.rfc5545.recur.RecurrenceRule.iterator(RecurrenceRule.java:2140)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions