Skip to content

Commit 6776e65

Browse files
bm1549claude
andcommitted
Add deterministic reproduction delay to Spring scheduling cron test
After closing the Spring context (which stops the scheduler), add a sleep longer than the cron interval to prove that no extra traces appear even under worst-case timing. This makes the previously-flaky race condition fully deterministic: without context.close(), the sleep guarantees extra cron executions; with it, the scheduler is stopped and assertions pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 072361c commit 6776e65

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src/latestDepTest/groovy/SpringSchedulingTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class SpringSchedulingTest extends InstrumentationSpecification {
3333
// Close the context immediately after the first execution to prevent a second cron
3434
// firing before assertions complete, which would produce extra traces and cause flakiness.
3535
context.close()
36+
// Deterministic reproduction: sleep longer than the cron interval (5 s) to prove
37+
// that closing the context stopped the scheduler and no extra traces appear.
38+
Thread.sleep(6000)
3639

3740
expect:
3841
assert task != null

dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src/test/groovy/SpringSchedulingTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class SpringSchedulingTest extends InstrumentationSpecification {
3333
// Close the context immediately after the first execution to prevent a second cron
3434
// firing before assertions complete, which would produce extra traces and cause flakiness.
3535
context.close()
36+
// Deterministic reproduction: sleep longer than the cron interval (5 s) to prove
37+
// that closing the context stopped the scheduler and no extra traces appear.
38+
Thread.sleep(6000)
3639

3740
expect:
3841
assert task != null

0 commit comments

Comments
 (0)