You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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)
The text was updated successfully, but these errors were encountered:
SimonGustavsson
changed the title
Improve validation of intervals
Improve validation of intervals?
Mar 9, 2023
I guess the problem goes a bit deeper. The underlying datetime lib stores the year in just 18 bits. There will be an overrun in year 262144. At present I don't consider that an issue. That might change around the year 260000, though. If this lib is still in use by then, people might be worried about this issue. ;-)
I guess it makes sense to validate the interval value and limit it to some reasonable value. Not sure what a reasonable limit would be though. It probably depends on the FREQ value. For starters we could limit the interval to 0<n<10000000. That's probably a reasonable range. For a SECONDLY rule that would be an interval of about 7.6 years.
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:
Exception:
The text was updated successfully, but these errors were encountered: