NullPointerException in MultiStatusHandler when parsing Darwin Calendarserver response #129
Description
When syncing with a Darwin Calendarserver (DCS) 2.4.dfsg-6 (the version provided by Debian 6.0), sync fails with a NullPointerException:
I/SyncAdapter(20701): Event /calendars/users/oliver/birthdays/ androidUri=null D/CaldavFacade(20701): LastAuthState: restored with user oliver D/CaldavFacade(20701): LastAuthScope: restored E/SyncAdapter(20701): Updating calendar exception java.lang.NullPointerException E/SyncAdapter(20701): java.lang.NullPointerException E/SyncAdapter(20701): at org.gege.caldavsyncadapter.caldav.xml.MultiStatusHandler.endElement(MultiStatusHandler.java:56) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatParser.appendChars(Native Method) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:497) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:484) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:309) E/SyncAdapter(20701): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:267) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.caldav.entities.CalendarEvent.setICSasMultiStatus(CalendarEvent.java:153) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.caldav.CaldavFacade.getEvent(CaldavFacade.java:718) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.caldav.entities.CalendarEvent.fetchBody(CalendarEvent.java:262) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.caldav.entities.CalendarEvent.createAndroidEvent(CalendarEvent.java:900) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.syncadapter.SyncAdapter.synchroniseEvents(SyncAdapter.java:330) E/SyncAdapter(20701): at org.gege.caldavsyncadapter.syncadapter.SyncAdapter.onPerformSync(SyncAdapter.java:170) E/SyncAdapter(20701): at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:254) D/PhoneStatusBar( 683): addNotification score=0 D/SyncManager( 572): failed sync operation oliver@http://raidbox:8008/calendars/users/oliver/birthdays/ (org.gege.caldavsyncadapter.account), com.android.calendar, SERVER, earliestRunTime 10589637, SyncResult: stats [ numParseExceptions: 1] D/SyncManager( 572): not retrying sync operation because the error is a hard error: oliver@http://raidbox:8008/calendars/users/oliver/birthdays/ (org.gege.caldavsyncadapter.account), com.android.calendar, SERVER, earliestRunTime 10594318 D/dalvikvm( 683): GC_CONCURRENT freed 3464K, 48% free 5122K/9735K, paused 15ms+33ms, total 168ms D/dalvikvm( 683): WAIT_FOR_CONCURRENT_GC blocked 146ms D/SyncManager( 572): setSyncAutomatically: provider com.android.calendar, user 0 -> false
This is the XML response which triggers the crash:
<?xml version='1.0' encoding='UTF-8'?><multistatus xmlns='DAV:'>
<response>
<href>/calendars/users/oliver/birthdays/</href>
<status>HTTP/1.1 404 Not Found</status>
</response>
</multistatus>
So the crash occurs because there is no mPropStat
object yet, because the <status>
tag isn't embedded in a <propstat>
tag at all.
I think the full story is:
- ACSA sends an initial "PROPFIND /calendars/users/oliver/birthdays/" request
- DCS responds with an XML message with lots of
<response>
tags (see below) - the first
<response>
tag is not an event but the calendar itself (!) - ACSA sends REPORT requests for all
<response>
tags, beginning with "REPORT /calendars/users/oliver/birthdays/" - DCS responds with the 404 XML response which then triggers the crash
Here's the beginning of the DCS response to the initial PROPFIND request:
<?xml version='1.0' encoding='UTF-8'?><multistatus xmlns='DAV:'>
<response>
<href>/calendars/users/oliver/birthdays/</href>
<propstat>
<prop>
<displayname>Geburtstage</displayname>
<resourcetype>
<collection/>
<calendar xmlns='urn:ietf:params:xml:ns:caldav'/>
</resourcetype>
<calendar-color xmlns='http://apple.com/ns/ical/'>#ff4e50ff</calendar-color>
<getctag xmlns='http://calendarserver.org/ns/'>2013-10-14 22:19:01.369242</getctag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/calendars/users/oliver/birthdays/10D9838F-2374-4E55-8A24-33AFD79B541E.ics</href>
<propstat>
<prop>
<displayname>10D9838F-2374-4E55-8A24-33AFD79B541E.ics</displayname>
<resourcetype/>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
<propstat>
<prop>
<calendar-color xmlns='http://apple.com/ns/ical/'/>
<getctag xmlns='http://calendarserver.org/ns/'/>
</prop>
<status>HTTP/1.1 404 Not Found</status>
</propstat>
</response>
...