Skip to content

[DOXIA-698] Make Sink implement AutoCloseable - #160

Merged
elharo merged 1 commit into
masterfrom
sink2
Mar 28, 2023
Merged

elharo merged 1 commit into
masterfrom
sink2

Conversation

@elharo

@elharo elharo commented Mar 25, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@elharo
elharo requested a review from michael-o March 28, 2023 13:03

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait a second. Who will close the writer or stream passed? Impl is required?

@elharo

elharo commented Mar 28, 2023

Copy link
Copy Markdown
Contributor Author

That behavior doesn't change. If a Sink implementation closes the stream/writer when the sink is closed, then it will still be closed when stream/writer is autoclosed. If the Sink implementation doesn't close the stream/writer when the sink is closed, then it won't be closed now. Nothing in this PR changes what happens when a Sink's close method is invoked. It just enables try-with-resources to be used to implicitly invoke the close method instead of explicitly calling it. This makes for slightly simpler code and makes resource leaks where the sink isn't closed at all less likely.

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense.

@elharo
elharo merged commit b113dc7 into master Mar 28, 2023
@elharo
elharo deleted the sink2 branch March 28, 2023 14:56
@jira-importer

Copy link
Copy Markdown

Resolve #835

@slachiewicz slachiewicz added this to the 2.1.0 milestone Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants