[IO-438] Clarify IOUtils.closeQuietly() Javadocs#857
Open
sarankumarbaskar wants to merge 2 commits into
Open
Conversation
Remove examples that quietly close output streams after copy operations, and document when close failures should not be ignored.
garydgregory
requested changes
Jun 12, 2026
garydgregory
left a comment
Member
There was a problem hiding this comment.
@Sarankumar18
Don't delete examples, propose new ones.
…Show output streams being closed normally before falling back to closeQuietly() for cleanup.
Contributor
Author
|
@garydgregory |
garydgregory
requested changes
Jun 12, 2026
garydgregory
left a comment
Member
There was a problem hiding this comment.
@Sarankumar18
Please see my comments.
| * } finally { | ||
| * IOUtils.closeQuietly(inputStream); | ||
| * IOUtils.closeQuietly(outputStream); | ||
| * IOUtils.closeQuietly(outputStream); // only if normal close was skipped |
Member
There was a problem hiding this comment.
@Sarankumar18
This example makes no sense to me:
- First, you
close()the OS on line 809 with the contradictory comment "close errors are handled"; the close() call does not handle errors. - Second, in the finally block, the comment "only if normal close was skipped" is not true because the finally block is always executed.
Please come up with an example and comments that make sense and are consistent with what actually happens.
TY
| * try { | ||
| * return IOUtils.copy(inputStream, outputStream); | ||
| * IOUtils.copy(inputStream, outputStream); | ||
| * outputStream.close(); // close errors are handled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IOUtils.closeQuietly() ignores exceptions thrown during close, which is useful for cleanup paths but can be unsafe when closing output streams or writers after successful writes.
This PR clarifies the Javadocs to warn that output close failures may indicate buffered data was not fully written. It also removes examples that used closeQuietly() after IOUtils.copy(), since those examples could encourage ignoring output close errors.
No runtime behavior changed.
Resolves IO-438.
Checklist:
mvn -Drat.skip=true -DskipTests javadoc:javadoc