Fix ManualTime.expectNoMessageFor async delivery race#3329
Open
He-Pin wants to merge 1 commit into
Open
Conversation
Motivation: ManualTime.expectNoMessageFor used a zero-timeout probe poll after advancing manual time, allowing asynchronously dispatched messages to be missed. Modification: Use the configured no-message timeout in both Scala and Java DSLs, document the behavior, and add deterministic regression coverage for delayed delivery. Result: ManualTime.expectNoMessageFor now fails when a message triggered during the time advance reaches a probe asynchronously. Tests: - sbt "+actor-testkit-typed / Test / testOnly org.apache.pekko.actor.testkit.typed.scaladsl.ManualTimeSpec" (passed on Scala 2.13.18 and 3.3.8) - sbt "actor-testkit-typed / Test / test" (175 total, 174 passed, 1 ignored) - sbt "+headerCheckAll" (passed) - sbt checkCodeStyle (passed) - native scalafmt diff and new-file checks (passed) - Qoder stdout review (no must-fix findings) - sbt sortImports (environment failure: Scalafix/Scalameta NoSuchMethodError) - sbt validatePullRequest (interrupted at user request) References: Fixes apache#3235
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.
Motivation
ManualTime.expectNoMessageFor advanced manual time and then polled each probe with a zero timeout. Scheduler tasks run synchronously, but actor mailbox processing and probe delivery remain asynchronous, so the assertion could pass before an unexpected message reached the probe.
Modification
Use each probe’s configured no-message timeout in both the Scala and Java DSLs. Document the post-advance observation window and add deterministic regression tests using a blocked single-thread dispatcher for both APIs.
Result
Unexpected messages triggered during a manual time advance are observed reliably instead of being missed by a non-blocking poll.
References
Fixes #3235