Open Amplifino opened 8 years ago
Can you please provide a full stack trace? This may be a thread safety issue where one thread calls activate which writes the executor field while another thread calls after which reads the executor field.
It is not a thread issue, simply the fact that SCR calls the addSchedule before the activate for any existing CronJog services at component activation time. (I should have stressed that I am using the whiteboard approach for scheduling services).
Easy to reproduce if you stop and then start the scheduler bundle while you have CronJob Services with a valid CRON property.
Stack trace:
okt 19, 2016 3:14:19 PM osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl addSchedule
SEVERE: Invalid cron expression 0 * * * * ? from {service.id=108, objectClass=[Ljava.lang.String;@1b934c2d, component.name=eu.vandevelde.playground.impl.CronSample, cron=0 * * * * ?, service.scope=bundle, component.id=61, service.bundleid=40}
java.lang.NullPointerException
at osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl.after(InternalSchedulerImpl.java:90)
at osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl.at(InternalSchedulerImpl.java:285)
at osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl.schedule(InternalSchedulerImpl.java:211)
at osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl.schedule(InternalSchedulerImpl.java:269)
at osgi.enroute.scheduler.simple.provider.InternalSchedulerImpl$Cron.
Thanks for the stacktrace. There is definitely a bug in that the bind methods depend upon state set by the activate method. And the bind methods can be called before the activate method.
At startup a NPE occurs in InterschedulerImpl at line 90 because the addSchedule method is called by SCR before the activate method.
A simple fix is to drop the activate method and initialize the ScheduledExecutorService at field declaration.