quartznet icon indicating copy to clipboard operation
quartznet copied to clipboard

QuartzScheduler: idleWaitTime that is zero (or less) is silently ignored

Open drieseng opened this issue 3 years ago • 5 comments

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?

drieseng avatar Nov 07 '21 21:11 drieseng

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 avatar Nov 08 '21 06:11 lahma

@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?

drieseng avatar Nov 11 '21 09:11 drieseng

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 avatar Nov 11 '21 17:11 lahma

@lahma Can you point to me to the code where we dynamically set this property on QuartzSchedulerThread?

drieseng avatar Nov 14 '21 12:11 drieseng

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.

lahma avatar Nov 14 '21 14:11 lahma