Details
Description
Hello,
I have observed a memory leak for Quartz worker thread in case an exception is thrown during
the scheduling phase when schedule is set to past time.
I have observed this issue with camel-quart 2.10.4, 2.11.0, 2.11.2 versions.
For ex, assuming today is 4-Oct; If a schedule is provided for yesterday (i.e 3-Oct) then
below sequence happen:
1. Quartz create worker thread for new schedule [generally TEN Threads with name 'DefaultQuartzScheduler']
2. Camel-quartz increment jobCounter for scheduler context [using QuartzComponent.incrementJobCounter()]
3. Camel-quartz tries to create new schedule [using Scheduler.scheduleJob()]
4. scheduleJob() throws SchedulerException with the message - 'Based on configured schedule,
the given trigger will never fire'
5. Camel-quartz does NOT decrement the job counter and jobCounter value remains '1'
6. Later Camel-Quartz stops the route and call QuartzComponent.doStop()
7. In doStop(), Scheduler.shutdown() supposed to be called so that those TEN threads are
removed but to call shutdown() the pre-condition is that the jobCounter should be '0'. In
this case jobCounter is '1' and Scheduler.shutdown() will NOT be called and those TEN threads
are NOT removed. This is memory leak.
Please find the stack trace in attachment 'memory_leak_scheduler_stack_trace.log' [with Camel-Quartz 2.11.2 and org.apache.servicemix.bundles.quartz-1.8.6_1
which wrapped Quartz Scheduler as OSGi bundle] when SchedulerException is thrown at step
4 in above sequence.
Thanks,
Nurali