Fix mishandling of exceptions in UTC#442
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a crash in ICalendarGenerator.write when determining the earliest DTSTART across a main event and its recurrence exceptions, specifically when exceptions use a UTC Instant while the main event uses a ZonedDateTime (DAVx5 #898 scenario).
Changes:
- Add a regression test covering a recurring event whose exception
DTSTARTis a UTCInstant. - Normalize temporals before calling
TemporalAdapter.isBeforeto avoidDateTimeExceptionwhen comparing mixed temporal types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarGenerator.kt | Normalizes exception/main DTSTART values prior to comparison to prevent crashes on mixed temporal types. |
| lib/src/test/kotlin/at/bitfire/synctools/icalendar/ICalendarGeneratorTest.kt | Adds a test reproducing the UTC Instant exception DTSTART crash and asserting calendar output is produced. |
|
Is there an issue or did you discover that by chance? Is it related to #424 somehow (that is also about crash with Instant)? |
Issue is https://github.com/bitfireAT/davx5/issues/898 (which I forgot to add to Development Plan ... sorry - did so now) |
No, this is a fix for https://github.com/bitfireAT/davx5/issues/898
I don't think so, they come from different places |
Ah, nice, wasn't aware of that one! I linked it to the PR. |
I didn't link it originally so that we remember to update the synctools version in DAVx⁵ as well, but I guess it will eventually get updated anyway so |
Closes https://github.com/bitfireAT/davx5/issues/898
The
TemporalAdapter.isBeforecall inICalendarGenerator.writecrashed when comparing a UTCInstant(for example2025-08-22T03:30:00Zfrom an exception'sDTSTART) against aZonedDateTime(from the main event'sDTSTART), because ical4j internally triesZonedDateTime.from(Instant)which always throwsDateTimeException.Added a failing test that showcases the issue, and a fix for it.