8218280: LineNumberReader throws "Mark invalid" exception if CRLF straddles buffer.
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Apr 26 18:27:00 UTC 2019
Daniel,
I modified the test as shown below. It passes both before and after the implementation change.
Thanks,
Brian
--- a/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java
+++ b/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java
@@ -56,6 +56,24 @@
}
@Test
+ public static void testCRNotFollowedByLF() throws IOException {
+ final String string = "foo\rbar";
+ try (Reader reader =
+ new LineNumberReader(new StringReader(string), 5)) {
+ reader.read(); // 'f'
+ reader.read(); // 'o'
+ reader.read(); // 'o'
+ reader.read(); // '\r'
+ reader.mark(1); // mark position of next character
+ reader.read(); // 'b'
+ reader.reset(); // reset to position after '\n'
+ assertEquals(reader.read(), 'b');
+ assertEquals(reader.read(), 'a');
+ assertEquals(reader.read(), 'r');
+ }
+ }
+
+ @Test
> On Apr 26, 2019, at 4:23 AM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
>
> I had to convince myself that there was no issue when
> '\r' is not followed by '\n' but I couldn't fault the
> logic.
>
> I wonder if adding a third test case with '\r' not
> followed by '\n' would be a good idea?
More information about the core-libs-dev
mailing list