quartznet
quartznet copied to clipboard
QuartzScheduler: idleWaitTime that is zero (or less) is silently ignored
When idleWaitTime is TimeSpan.Zero (or less), it is silently ignored by QuartzScheduler and, as result, the default idle wait time of 30 seconds is used by QuartzSchedulerThread.
I'd propose to throw an ArgumentException either when idleWaitTime is TimeSpan.Zero or less, or - which is what I prefer - only reject idleWaitTime if it's negative.
Why reject an idleWaitTime that is TimeSpan.Zero, but allow one that represents a single tick?
Sounds good, we can reject the negative. Usually these are things that people purposefully try to shoot them to their legs when setting such values.
Zero value can be an accident though when integer value default as something wrong comes out of configuration with wrong key / missing value.
@lahma I'm preparing a PR for this (and a few other changes), but I wonder why we do not have an IdleWaitTime property on QuartzSchedulerResources. Instead it is passed as an extra argument in the QuartzScheduler ctor. Is this something I can change as well?
Also, the (internal) IdleWaitTime property on QuartzSchedulerThread has a TimeSpanParseRule custom attribute:
[TimeSpanParseRule(TimeSpanParseRule.Milliseconds)]
internal virtual TimeSpan IdleWaitTime
Is this effectively used?
You can configure the idleWaitTime
via scheduler property https://www.quartz-scheduler.net/documentation/quartz-3.x/configuration/reference.html#main-configuration but attribute should only be considered when using reflection or the default job factory to dynamically set values.
@lahma Can you point to me to the code where we dynamically set this property on QuartzSchedulerThread?
I don't think we do, but the only way the attribute would be considered is using the reflection tools that do the required conversion.