NPEs in Astro binding

After installing nightly build #662, I noticed several NullPointerExceptions in my log file. Build 662 includes the new version of the Astro binding that supports events. I deleted my existing Astro things, and then re-added them. So far the NPEs have not reoccurred. I presume there’s an incompatibility between the new Astro binding and the old things.

In case anyone else runs into this, here are some samples of the exceptions.

2016-12-22 17:05:00.002 [ERROR] [org.quartz.core.JobRunShell         ] - Job astro:sun:local.job-event-end-civilDusk#event threw an unhandled Exception: 
java.lang.NullPointerException
        at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
2016-12-22 17:05:00.003 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (astro:sun:local.job-event-end-civilDusk#event threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
Caused by: java.lang.NullPointerException
        at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        ... 1 more
2016-12-22 17:05:00.004 [ERROR] [org.quartz.core.JobRunShell         ] - Job astro:sun:local.job-event-start-nauticDusk#event threw an unhandled Exception: 
java.lang.NullPointerException
        at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
2016-12-22 17:05:00.004 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (astro:sun:local.job-event-start-nauticDusk#event threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
Caused by: java.lang.NullPointerException
        at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[183:org.openhab.binding.astro:2.0.0.201612221443]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612221226]
        ... 1 more

same here…

2016-12-23 06:48:00.323 [ERROR] [org.quartz.core.JobRunShell         ] - Job astro:sun:local.job-event-end-astroDawn#event threw an unhandled Exception: 
java.lang.NullPointerException
	at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
2016-12-23 06:48:00.323 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (astro:sun:local.job-event-end-astroDawn#event threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
Caused by: java.lang.NullPointerException
	at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	... 1 more
2016-12-23 06:48:00.324 [ERROR] [org.quartz.core.JobRunShell         ] - Job astro:sun:local.job-event-start-nauticDawn#event threw an unhandled Exception: 
java.lang.NullPointerException
	at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
2016-12-23 06:48:00.324 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (astro:sun:local.job-event-start-nauticDawn#event threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
Caused by: java.lang.NullPointerException
	at org.openhab.binding.astro.handler.AstroThingHandler.triggerEvent(AstroThingHandler.java:304)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.EventJob.executeJob(EventJob.java:32)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.openhab.binding.astro.internal.job.AbstractBaseJob.execute(AbstractBaseJob.java:39)[179:org.openhab.binding.astro:2.0.0.201612221443]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[102:org.eclipse.smarthome.core.scheduler:0.9.0.201612091054]
	... 1 more

can you confirm re-creating your things did the trick? my errors appear very irregular and don’t seem to affect anything.

I have not seen it occur since I recreated the things, which as of this post is about 14 hours ago.

The errors may appear irregular, but it looks to me like they occur whenever an event occurs. The old Astro things don’t have the new event channels. From what I can see, the code assumes the channels are there; and generates an NPE when the binding tries to generate an event on one of those channels. I’m pretty confident recreating the things will solve the problem.

yes, you are right:

and the errors are:

2016-12-25 08:05:01.316 [ERROR] [org.quartz.core.JobRunShell ] - Job astro:sun:local.job-event-end-civilDawn#event threw an unhandled Exception:
java.lang.NullPointerException

and

2016-12-25 16:26:01.348 [ERROR] [org.quartz.core.JobRunShell ] - Job astro:sun:local.job-event-end-set#event threw an unhandled Exception:
java.lang.NullPointerException

i will also try to recreate the things to get rid of these messages.

thanks!

I can confirm, recreating the things resolved the issues!