-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quarkus-scheduler trigger getNextFireTime does not consider cron timezone #41717
Comments
The |
Hi @mkouba - thanks for chipping in. I tried putting in a work around by returning the Instant and then forcing it into the timezone, using the methods you mention, but that has the consequence that it can return "nextFireTime" of an event that has already triggered (i.e. in the past). As the scheduled job has the capability of defining a timezone, then that must be considered when returning a timezone agnostic Instant. The Instant of 20:30 London is not the same as the Instant of 20:30 Berlin. |
Of course, it isn't. And I agree that it's confusing. It works like this - all Now if I have In your code, Does that make sense? Would it help if we clarify the javadoc in a way that |
Hi, Thanks for sticking with me!
Shouldn't this return I always get the same Instant for both cron schedules, so the Out of interest, if you try the same experiment, using a cron schedule of 10-15mins in your future with a more easterly timezone, e.g. Europe/Istantbul, do you get a value for today? Or is it correctly recognising that the trigger actually will next take place tomorrow? In case it helps, here is my output: Expanded test class:
OUTPUT:
Expected result:
|
And just to clarify, the triggering itself is working fine. The jobs are only actually triggered at the expected times. |
Not really. I've tried to explain in my previous comment that the next fire time is always derived from the default time zone. So if you have a cron
That is expected, although not very clear. I will try to improve the wording of the javadoc and send a PR tomorrow. |
OK, but that's not the correct value for This example showing a trigger highlights it.
|
That's a good point and indeed it does not make a lot of sense from this point of view. So I tested the I will send a PR tomorrow. We should be consistent here. |
Thanks @mkouba - really appreciate your persistence. |
- fixes quarkusio#41717 (cherry picked from commit 30af1a6)
Describe the bug
When using the Quarkus Scheduler, cron triggering works properly with respect to the configured timezone. However, when interrogating the scheduler for the "getNextFireTime", the timezone is not factored in. This results in incorrect behaviour, most problematically, is that it can return a next fire time in the past.
See example class which demonstrates the results coming back.
Expected behavior
When calling getNextFireTime from the scheduler, the Instant returned should match the actual nextFireTime defined by the cron AND timezone, not simply the cron as parsed in the local timezone.
Actual behavior
When calling getNextFireTime from the scheduler, the Instant returned treats the cron as if it had the local timezone.
How to Reproduce?
Output of
uname -a
orver
Linux alan-test-redis-cacher-56d9f6f6d4-ssstk 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "21.0.1" 2023-10-17 LTS
Quarkus version or git rev
3.10.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: