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

Fix destructor behavior of BufferedStream #2757

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

s-ludwig
Copy link
Member

Since BufferedStream has RAII semantics, the destructor performs an implicit flush to and of the underlying stream, which can in turn throw an exception. In order to still let the destruction happen semantically, any such exception is now rethrown after performing a full clean-up. This means that the data that has not been flushed will be lost, but the state of the object will be so that another destroy() call will be a no-op and no resources are referenced anymore.

Since BufferedStream has RAII semantics, the destructor performs an implicit flush to and of the underlying stream, which can in turn throw an exception. In order to still let the destruction happen semantically, any such exception is now rethrown after performing a full clean-up. This means that the data that has not been flushed will be lost, but the state of the object will be so that another destroy() call will be a no-op and no resources are referenced anymore.
@s-ludwig s-ludwig merged commit b6b2692 into master Nov 27, 2023
74 checks passed
@s-ludwig s-ludwig deleted the fix_bufferedstream_destructor branch November 27, 2023 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants