Make AppendableWriter do flush and close if delegation object supports#2925
Make AppendableWriter do flush and close if delegation object supports#2925eamonnmcmanus merged 2 commits intogoogle:mainfrom
Conversation
eamonnmcmanus
left a comment
There was a problem hiding this comment.
This seems very reasonable. I ran the change against all of Google's internal tests and did not see any problems.
|
In Java I rarely see a class which implements both Appendable and one of Flushable/Closable while it's not a |
Yes, you are probably right. One such case is However, it seems for all cases where And I agree that this is a reasonable change. Footnotes
|
Purpose
Streams.writerForAppendableallows us to wrap anAppendableinto aWriter. In the old implementation, the wrapped Writer does nothing on invocation offlushandclose. Imagine we wrapped an object which implements bothAppendableandCloseable, this might confuse the user.Description
If the wrapped object implements
FlushableorCloseable, the corresponding function will be delegated to the Writer.Checklist
This is automatically checked by
mvn verify, but can also be checked on its own usingmvn spotless:check.Style violations can be fixed using
mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.null@since $next-version$(
$next-version$is a special placeholder which is automatically replaced during release)TestCase)mvn clean verify javadoc:jarpasses without errors