fix(scheduler): correct spacedDelay unit mismatch with withNoOverlaps() + aligned start time - #693
Merged
Conversation
…() + aligned start time withNoOverlaps() snapshotted spacedDelay from period before the start-time alignment (between()/startOnTime()) converted period/timeUnit to seconds, leaving spacedDelay in the original unit while timeUnit had already changed. scheduleWithFixedDelay() then applied the new seconds-based timeUnit to the stale spacedDelay value, causing tasks like every(1,"minutes").between(...).withNoOverlaps() to re-fire every second instead of every 60 seconds. Moves the noOverlaps -> spacedDelay snapshot to after start-time alignment so it always reads the already-converted period/timeUnit. Fixes COLDBOX-1434 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013HqnErWoJMwuTHANY4gaL1
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.
Description
ScheduledTasktasks combining.withNoOverlaps()with a daily start-time window (.between()/.startOnTime()) were re-firing far more frequently than configured — e.g.every( 1, "minutes" ).between( "07:00", "18:00" ).withNoOverlaps()fired roughly every 1 second instead of every 60 seconds.Root cause: in
ScheduledTask.cfcstart(), thenoOverlaps -> spacedDelaysnapshot (spacedDelay = period) ran beforecalculateStartTimeAlignedDelay()convertedperiod/timeUnitinto seconds.spacedDelaywas left holding the value in its original unit (e.g.1for "1 minute") whiletimeUnithad already changed to"seconds".ScheduledExecutor.scheduleWithFixedDelay()applies a singletimeUnitto bothdelayandspacedDelay, so the JDK scheduled a 1-second repeat instead of 60.Fix: move the
noOverlaps -> spacedDelaysnapshot to after the start-time alignment call, so it always derives from the already-convertedperiod/timeUnit. Tasks with nostartTime(which never hit the alignment/conversion path) are unaffected.Jira Issues
Type of change
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_013HqnErWoJMwuTHANY4gaL1
Generated by Claude Code