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

Tweak CachingHelpers.GetCacheKey to clean up better on failure #5654

Merged
merged 2 commits into from
Nov 19, 2024

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Nov 16, 2024

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub merged commit 476a196 into dotnet:main Nov 19, 2024
6 checks passed
stephentoub added a commit to stephentoub/extensions that referenced this pull request Nov 19, 2024
// If we start using an instance, write to it, and then fail, we will have left it
// in an inconsistent state. So, when renting it, we null it out, and we only put
// it back upon successful completion after resetting it.
IncrementalHashStream.ThreadStaticInstance = null;
Copy link
Member

Choose a reason for hiding this comment

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

Why not just dispose it in a try/finally? Is it expected that this could be called recursively?

Copy link
Member Author

Choose a reason for hiding this comment

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

It shouldn't be disposed if it's going to be cached. So it's disposed in a catch rather than a finally.

@stephentoub stephentoub deleted the cachingcleanup branch November 20, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants