PR: Introduce pluggable TimeBroker as replacement for system clock - #1417
PR: Introduce pluggable TimeBroker as replacement for system clock#1417ThanosTsiamis wants to merge 6 commits into
Conversation
e2f422b to
5db3b7b
Compare
78804b5 to
882c14f
Compare
|
Hi there reviewers! |
Signed-off-by: Thanos Tsiamis <thanos.tsiamis@allwyn-lotterysolutions.com>
…moval Signed-off-by: Thanos Tsiamis <thanos.tsiamis@allwyn-lotterysolutions.com>
… stability Signed-off-by: Thanos Tsiamis <thanos.tsiamis@allwyn-lotterysolutions.com>
Signed-off-by: Thanos Tsiamis <thanos.tsiamis@allwyn-lotterysolutions.com>
ea97ff9 to
093cc98
Compare
|
Hey maintainers! :) Any thoughts on this? |
A few more words on the PRIn complex, distributed multi-service architectures, testing time-dependent logic is notoriously painful. Because Quartz has historically been hard-wired to System.currentTimeMillis(), simulating "time travel" or testing edge cases (like daylight saving shifts or specific execution gaps) requires altering the host system clock—which messes up everything else. Deterministic Testing: A pluggable TimeBroker allows us to inject a frozen or fast-forwarded virtual clock during integration tests. Cluster Synchronization: It gives teams the flexibility to hook into external time synchronization mechanisms if their environment demands it. Backwards Compatibility CheckLooking through the implementation details and the files changed, this PR is incredibly safe and fully backwards compatible: Zero Behavior Drift by Default: If the new property Smart Asset Reuse: Instead of introducing a brand-new, breaking API type, this simply wires up and leverages the pre-existing TimeBroker SPI. This is a massive quality-of-life win for modern testing setups with zero risk to legacy configurations. @jhouserizer @melloware Let me know your thoughts =] |
|
Greetings @melloware! |
|
@ThanosTsiamis only @jhouserizer can merge PRs. I only have review privileges. |
Thanks for clarifying, @melloware! 🙌 =] Since the branch requires 2 approving reviews before it can be merged, a review or feedback from your side would still be immensely helpful in moving this forward. Whenever you have a moment, I'd really appreciate your thoughts on the code changes! If you're unavailable, is there anyone else you'd suggest reaching out to alongside @jhouserizer? |
This PR addresses Provide TimeProvider #1372, which requested a way to replace Quartz’s hard-wired use of System.currentTimeMillis() with a pluggable, testable, and customizable time source.
Quartz previously had an SPI called TimeBroker, but it was deprecated and never wired through the scheduler. This PR revives and integrates that interface as the official mechanism for controlling Quartz’s notion of “current time.”
Important note: No change in default behavior
If no custom TimeBroker is provided, Quartz continues to use:
SimpleTimeBroker → new Date() → System.currentTimeMillis()so backward compatibility is preserved.
Solves issue: #1372
Benefits
Checklist
git commit -son my commits, and submit this code under terms of the Apache 2.0 license and assign copyright to the Quartz project owners(If you're not using command-line, you can use a browser extension )
In submitting this contribution, I agree to the terms of contributing as referred to here:
https://github.com/quartz-scheduler/contributing/blob/main/CONTRIBUTING.md