google / google/error-prone

OutputStream implements flush() but close() does not invoke it

Open
#325 0 comments 0 reactions 0 assignees View on GitHub
Type-NewCheck
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

Closing an OutputStream could discard unflushed bytes. While nothing in the spec explicitly forbids that behavior, no user would expect it, and an "always flush before you close" guideline would be a burden that would never pay for itself.

Can we detect OutputStreams that have this problematic behavior somehow? Unfortunately, I'm sure we can't detect it very reliably, but we could do a smell test and accept some false positives....

I wanted to capture this idea but I am not sure it is worth worrying about.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.