Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispose archive stream after the list of DataStreams #80572

Merged
merged 2 commits into from
Jan 13, 2023

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented Jan 12, 2023

Follow-up of #79899 (comment)

@jozkee jozkee added this to the 8.0.0 milestone Jan 12, 2023
@jozkee jozkee self-assigned this Jan 12, 2023
Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test we could add that shows this breaking if the wrong order were used?

@jozkee
Copy link
Member Author

jozkee commented Jan 12, 2023

Taking a step back, it appears to me that if the archiveStream is disposed first, it doesn't harm the _dataStreamsToDispose, which is composed of [Seekable]SubReadStreams, since SubReadStream will effectively call _superStream.Read (where _superStream is the archiveStream from the ctor), it being disposed first will manifest in an ObjectDisposedException coming from archiveStream.

So, is just the call-stack that would be different.

Still, disposing the substreams first feels more correct.

@stephentoub to answer your question, I think there's no test that shows things breaking.

@jozkee jozkee merged commit 6774329 into dotnet:main Jan 13, 2023
@jozkee jozkee deleted the tarreader_dispose_order branch January 13, 2023 05:23
jozkee added a commit to jozkee/runtime that referenced this pull request Jan 13, 2023
* Dispose archive stream after the list of DataStreams

* Add tests for TarReader.DisposeAsync properly disposing underlying stream
carlossanlop pushed a commit that referenced this pull request Jan 13, 2023
… is false (#80598)

* TarReader should dispose underlying stream if leaveOpen is false (#79899)

* Dispose underlying stream in TarReader.DisposeAsync() as well (#79920)

* Dispose underlying stream in TarReader.DisposeAsync() as well

Same as #79899

* Consolidate duplicated WrappedStream test helpers to Common sources

* Dispose stream passed to WrappedStream

* Dispose archive stream after the list of DataStreams (#80572)

* Dispose archive stream after the list of DataStreams

* Add tests for TarReader.DisposeAsync properly disposing underlying stream

Co-authored-by: Alexander Köplinger <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Feb 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants