openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.7k forks source link

[caldavio] empty event titles crash calendar import #5008

Closed buxit closed 7 years ago

buxit commented 7 years ago

if there is a calendar event with an empty title, the importer crashes and imports no other events.

2017-01-17 06:10:11.475 [ERROR] [caldav.internal.job.EventReloaderJob] - error while loading calendar entries: null
java.lang.NullPointerException
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:321)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:279)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:111)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[104:org.eclipse.smarthome.core.scheduler:0.9.0.201610101820]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[104:org.eclipse.smarthome.core.scheduler:0.9.0.201610101820]
2017-01-17 06:10:11.476 [INFO ] [org.quartz.core.JobRunShell         ] - Job event-reloader.commands threw a JobExecutionException:
org.quartz.JobExecutionException: error while loading calendar entries [See nested exception: java.lang.NullPointerException]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:134)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[104:org.eclipse.smarthome.core.scheduler:0.9.0.201610101820]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[104:org.eclipse.smarthome.core.scheduler:0.9.0.201610101820]
Caused by: java.lang.NullPointerException
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:321)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:279)[199:org.openhab.io.caldav:1.9.0.201610120713]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:111)[199:org.openhab.io.caldav:1.9.0.201610120713]
    ... 2 more
9037568 commented 7 years ago

Which version of OH is this from?

buxit commented 7 years ago

i tested this with a prerelease version of oh 2.0 from winter 2016/2017. not sure how to read out the version of oh as it is conglomerate of lots of different packages.

org.openhab.io.caldav:1.9.0.201610120713 apparently doesn't give enough info?

buxit commented 7 years ago

branch beta3 seems to match. see: https://github.com/openhab/openhab1-addons/blob/beta3/bundles/io/org.openhab.io.caldav/src/main/java/org/openhab/io/caldav/internal/job/EventReloaderJob.java#L321 https://github.com/openhab/openhab1-addons/blob/beta3/bundles/io/org.openhab.io.caldav/src/main/java/org/openhab/io/caldav/internal/job/EventReloaderJob.java#L279

9037568 commented 7 years ago

Here's a test jar that I think should fix the problem. I've been unable to verify as I can't find a way to set a null title in Google calendar.

Can you try this out and see what you get?

buxit commented 7 years ago

still looks similar:

16:43:04.387 [INFO ] [core.karaf.internal.FeatureInstaller] - Installed 'openhab-binding-caldav-command1'
16:43:04.402 [INFO ] [smarthome.event.ExtensionEvent      ] - Extension 'binding-caldav-command1' has been installed.
16:43:19.787 [ERROR] [caldav.internal.job.EventReloaderJob] - error while loading calendar entries: null
java.lang.NullPointerException
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:397)[180:org.openhab.io.caldav:1.10.0.201703260421]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:316)[180:org.openhab.io.caldav:1.10.0.201703260421]
    at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:135)[180:org.openhab.io.caldav:1.10.0.201703260421]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612171108]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612171108]

(for future tests: is there a faster alternative to rm -r cache in order to make it load the new code?)

9037568 commented 7 years ago

It appears I overlooked an occurrence of the getSummary() call. I updated the jar; try downloading it again and see what you get.

I wouldn't have thought clearing the cache would be necessary, though.

buxit commented 7 years ago

this seems to fix it.

9037568 commented 7 years ago

Great. I have a little testing left to do, then I'll create a PR.

buxit commented 7 years ago

i wonder if it wouldn't make more sense to return a valid value from getSummary(), even if the title was empty. similar crashes may otherwise surface in other places.

9037568 commented 7 years ago

We don't have control of getSummary(), since it's an ical4j method.

You could try logging a defect against ical4j.