BITMAG-1248 Replace java.util.Timer with ScheduledExecutorService + virtual threads - #97
Open
Knud-Aage wants to merge 4 commits into
Open
BITMAG-1248 Replace java.util.Timer with ScheduledExecutorService + virtual threads #97Knud-Aage wants to merge 4 commits into
Knud-Aage wants to merge 4 commits into
Conversation
An uncaught exception in any TimerTask silently kills the whole timer thread. ScheduledExecutorService is the recommended replacement, and combined with virtual threads it lets each firing run independently without needing a bounded thread pool.
…eduled-executor-service
…eduled-executor-service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
java.util.Timer runs every scheduled task on a single shared thread, and an uncaught exception in any TimerTask silently kills that thread — every other job scheduled on it stops firing with no error surfaced. This replaces all Timer/TimerTask usage with a new
ScheduledVirtualThreadExecutor.
ScheduledVirtualThreadExecutor (bitrepository-core) pairs a single-thread ScheduledExecutorService "ticker" — which only decides when to fire — with a virtual-thread-per-task executor that actually runs each firing. This means:
Converted call sites (TimerTask → Runnable, Timer → ScheduledVirtualThreadExecutor):
JobScheduler gained a shutdown() method, threaded through WorkflowManager.shutdown() and called from IntegrityServiceManager and Pillar.close(), so the scheduler's executors are actually released on shutdown instead of leaking threads.
Added ScheduledVirtualThreadExecutorTest and TimerBasedSchedulerTest to cover the new scheduling behavior.