test: make mapWithResource abrupt cleanup tests deterministic#3319
Merged
He-Pin merged 1 commit intoJul 10, 2026
Conversation
Motivation: The abrupt materializer termination tests used Source.single, which can complete across mapWithResource's async boundary and close the resource before shutdown. Modification: Keep the upstream open with Source.maybe and assert that the resource has not been closed before shutting down the materializer. Result: The tests now distinguish abrupt termination cleanup from normal upstream completion. Tests: - FlowMapWithResourceSpec on Scala 2.13 and Scala 3 - sbt +headerCheckAll - sbt checkCodeStyle - sbt validatePullRequest (3392 passed, 0 failed) References: Refs apache#3310
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
The abrupt materializer termination tests used Source.single. Since mapWithResource runs on the blocking I/O dispatcher, its async boundary can let Source.single complete and close the resource before materializer shutdown. The test can therefore observe normal upstream completion instead of the abrupt termination path.
Modification
Use Source.maybe in both abrupt termination variants so the upstream remains open. After resource creation, assert that cleanup has not run before shutting down the materializer.
Result
The tests now isolate abrupt termination from normal upstream completion and retain directional assertions that cleanup runs after shutdown, including exactly-once closure for AutoCloseable resources.
Verification
References
Fixes #3310