FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
In java.io.PrintStream.write(char[] buf): out.flush() is called for every found '\n' char in buf while it should be enough to call it only once (if buf contains '\n').
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Consider the following code:
System.out.print(new char[] { '\n', '\n'});
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
out.flush() is called twice.
ACTUAL -
out.flush() should be called once.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n')
out.flush();
}
->
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n') {
out.flush();
break;
}
}
A DESCRIPTION OF THE PROBLEM :
In java.io.PrintStream.write(char[] buf): out.flush() is called for every found '\n' char in buf while it should be enough to call it only once (if buf contains '\n').
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Consider the following code:
System.out.print(new char[] { '\n', '\n'});
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
out.flush() is called twice.
ACTUAL -
out.flush() should be called once.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n')
out.flush();
}
->
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n') {
out.flush();
break;
}
}
- relates to
-
JDK-8025883 PrintStream "autoFlush" parameter violates its API contract
-
- Open
-