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

Cannot access a closed Stream on v21.1.2 #1162

Closed
rouke-broersma opened this issue Nov 8, 2024 · 2 comments · Fixed by #1163
Closed

Cannot access a closed Stream on v21.1.2 #1162

rouke-broersma opened this issue Nov 8, 2024 · 2 comments · Fixed by #1163
Labels
state: needs discussion Issues that need further discussion state: released Issues that are released type: bug Issues that describe misbehaving functionality

Comments

@rouke-broersma
Copy link

Describe the bug
Updating to v21.1.2 causes stream closed exceptions in our unit tests on dispose of the stream after it has already been closed or disposed by (I assume) System.Text.Json. I don't think we are using this wrong, but if I apologize in advance if this is user error.

Exception occurs on dispose after return of this line: https://github.com/stryker-mutator/stryker-net/blob/b7f9ccac7e384b14f7c21321006cbae4261f6d56/src/Stryker.Core/Stryker.Core/Baseline/Providers/DiskBaselineProvider.cs#L38

The stream is not used anywhere after that.

To Reproduce
Steps to reproduce the behavior:
Run unit tests Stryker.Core.UnitTest.Baseline.Providers: stryker-mutator/stryker-net#3100

Expected behavior
Disposing of FileStream should not cause an exception

Additional context

Stream appears to still be open

image

Exception on dispose

image

@rouke-broersma rouke-broersma added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Nov 8, 2024
vbreuss added a commit to vbreuss/System.IO.Abstractions that referenced this issue Nov 8, 2024
@vbreuss
Copy link
Member

vbreuss commented Nov 8, 2024

Sorry, @rouke-broersma, there must have slipped an issue with DisposeAsync.
I could reproduce the issue with the following minimal example:

  var fileSystem = new MockFileSystem();
  fileSystem.File.WriteAllText("foo.txt", "");
  {
      await using var reportStream = fileSystem.File.OpenRead("foo.txt");
  }

Will release a fix immediately!

Copy link

github-actions bot commented Nov 8, 2024

This is addressed in release v21.1.3.

@github-actions github-actions bot added the state: released Issues that are released label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion state: released Issues that are released type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants