RFR [6961766]: PrintStream.write() should flush at most once

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Aug 7 17:53:57 UTC 2013


Hello David!

Thanks for review.

> Yes - this is NOT A BUG this is the spec for this class:
>
> "Optionally, a PrintStream can be created so as to flush 
> automatically; this means that the flush method is automatically 
> invoked after a byte array is written, one of the println methods is 
> invoked, or a newline character or byte ('\n') is written. "
>
Sorry, I don't see how the proposed change would contradict the spec .
The code first writes a char[] buffer to an OutputStream, and then 
invokes flush() if the written array contained at least one '\n' char.

In addition to that, the documentation for OutputStream#flush() says: 
"Flushes this output stream and forces any buffered output bytes to be 
written out." Thus, there should be no point to have several subsequent 
calls to flush() with no data writes between them.

I don't insist on pushing this change, but I think it's harmless and may 
be useful.

Sincerely yours,
Ivan

> This bug report should be closed as "not an issue".
>
> David
> -----
>
>
>> -Alan
>
>




More information about the core-libs-dev mailing list