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 Properties.store(OutputStream os, String comment) #24

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

gastaldi
Copy link
Contributor

@gastaldi gastaldi commented Jul 8, 2024

This fixes the store method taking an OutputStream by flushing and closing the writer created to wrap it.

It also introduces ApprovalTests (https://approvaltests.com/) to open a diff window when comparing Strings and File contents

@quintesse
Copy link
Collaborator

Ok, first, good catch, the docs of Properties.load() does indeed say the stream should be flushed and the underlying stream not closed:

After the entries have been written, the output stream is flushed. The output stream remains open after this method returns.

(closing the writer doesn't close the stream, right? I never know and the docs are not clear)

Second... introducing a new way of testing? Awesome... are you going to migrate the rest of the tests as well? 😁 😛

@gastaldi
Copy link
Contributor Author

gastaldi commented Jul 9, 2024

(closing the writer doesn't close the stream, right? I never know and the docs are not clear)

Actually closing the writer flushes and then closes the stream. Maybe we should only flush it instead of closing in a try-with-resources block, I'll check.

Second... introducing a new way of testing? Awesome... are you going to migrate the rest of the tests as well?

I was thinking of leaving the other tests as an exercise for the reader 😉

@quintesse
Copy link
Collaborator

I was thinking of leaving the other tests as an exercise for the reader

Hahaha, ok, can I then ask a favor? Could you split the PR in two, one for this fix with a test that follows the same pattern as the other tests and then a new PR showing a single test converted to using that approvals library? I'll then use that PR as a basis for migrating all file-based tests to that system in the future.

@quintesse quintesse self-requested a review July 9, 2024 09:33
Copy link
Collaborator

@quintesse quintesse left a comment

Choose a reason for hiding this comment

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

Split into two PRs

This fixes the store method taking an `OutputStream` by flushing and closing the writer created to wrap it.
@gastaldi
Copy link
Contributor Author

gastaldi commented Jul 9, 2024

Created #26 (I'll rebase once this PR is merged)

@quintesse quintesse merged commit 2d98a64 into codejive:main Jul 9, 2024
1 check passed
@quintesse
Copy link
Collaborator

Thanks man! :-)

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.

Properties#store(OutputStream) doesn't flush the output to the OutputStream
2 participants