NullPointerException thrown when loading events from imported calendar
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
After importing a .ics calendar, its events will not load and the following stack trace is seen in the UI and in atlassian-confluence.log file:
Unable to load events of <Calendar-Name> (<Calendar-ID>): java.lang.NullPointerException at
com.atlassian.confluence.extra.calendar3.model.SubCalendarEvent.compareTo(SubCalendarEvent.java:700) at
com.atlassian.confluence.extra.calendar3.model.SubCalendarEvent.compareTo(SubCalendarEvent.java:27) at
java.util.ComparableTimSort.mergeLo(ComparableTimSort.java:684) at
java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:481) at
java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:404) at
java.util.ComparableTimSort.sort(ComparableTimSort.java:213) at
java.util.Arrays.sort(Arrays.java:1312) at java.util.Arrays.sort(Arrays.java:1506) at
java.util.ArrayList.sort(ArrayList.java:1462) at
java.util.Collections.sort(Collections.java:141) at
com.atlassian.confluence.extra.calendar3.ical4j.RecurrenceRuleProcessor.getRecurrenceEvents(RecurrenceRuleProcessor.java:222) at
com.atlassian.confluence.extra.calendar3.DefaultCalendarManager.getEvents(DefaultCalendarManager.java:717) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at
java.lang.reflect.Method.invoke(Method.java:498) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at
com.atlassian.plugins.spring.interceptor.plugin.ExportableInterceptorAdapter$WrappedMethodInvocation.proceed(ExportableInterceptorAdapter.java:53) at
com.atlassian.plugins.spring.interceptor.spi.SpringInterceptorAdapter$SpringMethodInvocationAdapter.proceed(SpringInterceptorAdapter.java:50) at
com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16) at
com.atlassian.plugins.spring.interceptor.spi.SpringInterceptorAdapter.invoke(SpringInterceptorAdapter.java:23) at
sun.reflect.GeneratedMethodAccessor485.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at
java.lang.reflect.Method.invoke(Method.java:498) at
com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) at
...
Note
This problem was only observed after importing calendars from third-party applications so far, not with .ics files from Team Calendars itself. Outlook calendars are an example that can face this issue.
Cause
By inspecting the source code, we can see that the NullPointerException comes from this line:
return name.compareTo(subCalendarEvent.name);
As we can see, this line looks for the event name, which is also referred as summary. This leads to believe that the calendar has events with Null or empty name/summary.
Workaround
Proceed as follows to confirm the problem and resolve it:
Import the problematic calendar into Team Calendars
- Export it again so TC will apply its own formatting to the .ics file
Open the .ics export in a text editor and search for this pattern:
SUMMARY:
Go over all matches and check if there are summaries empty
If empty summaries exist, add a temporary name to them, as in the example
SUMMARY:placeholdername
- Make sure that there are no empty summaries on the file and save it
Import the fixed .ics and confirm if you can load the events of the calendar