8230342: LineNumberReader.getLineNumber() returns inconsistent results after EOF

Reviewed-by: rriggs, dfuchs
This commit is contained in:
Brian Burkhalter 2019-09-11 12:32:01 -07:00
parent c920b4a5c0
commit 4285853d91
3 changed files with 66 additions and 9 deletions

View file

@ -25,7 +25,6 @@
package java.io;
/**
* A buffered character-input stream that keeps track of line numbers. This
* class defines methods {@link #setLineNumber(int)} and {@link
@ -200,9 +199,10 @@ public class LineNumberReader extends BufferedReader {
*/
public String readLine() throws IOException {
synchronized (lock) {
String l = super.readLine(skipLF);
boolean[] term = new boolean[1];
String l = super.readLine(skipLF, term);
skipLF = false;
if (l != null)
if (l != null && term[0])
lineNumber++;
return l;
}