Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Jena 3.15.0
-
None
Description
I observed that the blockSize does not control the actual size of the underlying char array 'buffer' which will result in ArrayIndexOutOfBounds.
Locally I added the test below to TestBufferingWriter.java to illustrate.
public void write_07 () { String alpha = "0123456789abcdefghijklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWZYZ"; create(8194, 4098); Random r = new Random(); for (int i = 0; i < 8194;i++) { w.output(alpha.charAt(r.nextInt(alpha.length()))); } w.close(); String x = string(); assertEquals(x.length(), 8194); }
Which produces.
[ERROR] write_07(org.apache.jena.atlas.io.TestBufferingWriter) Time elapsed: 0.007 s <<< ERROR! java.lang.ArrayIndexOutOfBoundsException: 8192 at org.apache.jena.atlas.io.TestBufferingWriter.write_07(TestBufferingWriter.java:112)