Fix double close in unfoldResource#3172
Merged
Merged
Conversation
Motivation: Source.unfoldResource could close the same resource twice when close(resource) failed. closeStage left the stage marked as open until after close returned, so postStop retried close after the failure. Modification: Mark the resource as no longer open before invoking close(resource) in closeStage. Add regression coverage for close failures during normal completion and downstream cancellation. Result: UnfoldResourceSource now reports the close failure without attempting to close the resource again from postStop. Tests: - rtk sbt "stream-tests / Test / testOnly org.apache.pekko.stream.scaladsl.UnfoldResourceSourceSpec" / passed - rtk scalafmt --mode diff-ref=origin/main / passed with JDK Unsafe deprecation warnings - rtk scalafmt --list --mode diff-ref=origin/main / passed with JDK Unsafe deprecation warnings - rtk git diff --check / passed - rtk sbt headerCreateAll / passed - rtk sbt "+headerCheckAll" / passed - rtk sbt checkCodeStyle / passed - rtk qodercli --help and qodercli stdout review with /tmp/project-review.diff / No must-fix findings - rtk sbt validatePullRequest / not completed locally: arm64 host cannot load leveldbjni-all 1.8 native library (available binary reports x86_64/i386, needs arm64); command was stopped after that environment failure References: Fixes apache#3162
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
Source.unfoldResource can close the same resource twice when close(resource) fails. closeStage left the stage marked as open until after close returned, so postStop retried close after the failure.
Modification
Mark the resource as no longer open before invoking close(resource) in closeStage.
Add regression coverage for close failures during normal completion and downstream cancellation.
Result
UnfoldResourceSource now propagates the close failure without attempting to close the same resource again from postStop.
Tests
rtk sbt "stream-tests / Test / testOnly org.apache.pekko.stream.scaladsl.UnfoldResourceSourceSpec"/ passedrtk scalafmt --mode diff-ref=origin/main/ passed with JDK Unsafe deprecation warningsrtk scalafmt --list --mode diff-ref=origin/main/ passed with JDK Unsafe deprecation warningsrtk git diff --check/ passedrtk sbt headerCreateAll/ passedrtk sbt "+headerCheckAll"/ passedrtk sbt checkCodeStyle/ passedrtk qodercli --helpand qodercli stdout review with/tmp/project-review.diff/ No must-fix findingsrtk sbt validatePullRequest/ not completed locally: arm64 host cannot loadleveldbjni-all:1.8native library. The extracted binary reports x86_64/i386 while this host needs arm64; command was stopped after that environment failure.References
Fixes #3162