mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
323 stars 44 forks source link

NPE when parsing REPLY without VERSION #48

Closed dankarp closed 8 years ago

dankarp commented 8 years ago

The following slightly-malformed REPLY:

BEGIN:VCALENDAR
METHOD:REPLY
BEGIN:VEVENT
DTSTAMP:20050317T164626Z
DTSTART:20050318T170000Z
UID:040000008200E00074C5B7101A82E00800000000A0DD17CECD2AC501000000000000000010000000DA4A35FDD8F70E4686F330A21558AF27
ATTENDEE;PARTSTAT=ACCEPTED;CN="Roland Schtroumpf":MAILTO:schtroumpf@example.com
LOCATION:866-555-3378, conf ID = 650-555-0500, passcode = 255455
DTEND:20050318T180000Z
END:VEVENT
END:VCALENDAR

Causes the following NPE:

Caused by: java.lang.NullPointerException: null
    at biweekly.io.scribe.property.AttendeeScribe._defaultDataType(AttendeeScribe.java:51) ~[biweekly-0.4.6.jar:na]
    at biweekly.io.scribe.property.ICalPropertyScribe.defaultDataType(ICalPropertyScribe.java:171) ~[biweekly-0.4.6.jar:na]
    at biweekly.io.text.ICalReader._readNext(ICalReader.java:301) ~[biweekly-0.4.6.jar:na]
    at biweekly.io.StreamReader.readNext(StreamReader.java:150) ~[biweekly-0.4.6.jar:na]
mangstadt commented 8 years ago

The problem was that, up until a VERSION property was read, the ICalVersion object that is used by the property-parsing code was set to null. To fix this, I initialized this object to "2.0", since this is the most commonly-used version, so you shouldn't get a NPE anymore.

You can use the ICalReader.setDefaultVersion() method to change the default version.

Fixed in d59f828f80e0f359eed18351f5e0743ec560f9a2.

Thanks for the report!