test: remove timing race in stopped-pending serialize test#290
Open
ZheSun88 wants to merge 1 commit into
Open
Conversation
Replace Thread.sleep-based serialization gating with a CountDownLatch so the second serialize() call always runs while the first serialization is still pending. The previous pattern relied on the 300 ms sleep outlasting awaitility's poll for !isRunning(); on slow runners the sleep could finish first, letting stop() shut down the executor before the second serialize() ran, which then hit RejectedExecutionException instead of taking the expected "wait for pending" branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Thread.sleep(300)inonSerializationSuccesswith aCountDownLatchso the secondserialize()call deterministically runs while the first serialization is still pending.serialize()on a separate thread (it now blocks inwaitForSerialization()) and assert it stays blocked until the latch is released, proving it took the "wait for pending" branch rather than the executor path.Why
The previous pattern relied on the 300 ms sleep outlasting awaitility's poll for
!isRunning(). On slow runners the sleep could finish first, lettingstop()shut down the executor before the secondserialize()ran. The second call would then fall through toCompletableFuture.runAsync(..., executorService)and throwRejectedExecutionException— observed on the validation run for #289 (job log) where dependency upgrades shifted timings enough to expose the race. This follows the sameCountDownLatchpattern introduced in #283 for two sibling tests.Test plan
mvn test -Dtest='SessionSerializerTest#serialize_applicationStopped_serializationRequestWhilePendingSerialization_ignoreAndWaitForCompletion'passes locally (5/5 runs).mvn test -Dtest='SessionSerializerTest'— full 25-test class passes.🤖 Generated with Claude Code