[
https://issues.apache.org/jira/browse/JENA-1919?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andy Seaborne resolved JENA-1919.
---------------------------------
Fix Version/s: Jena 3.16.0
Assignee: Andy Seaborne
Resolution: Fixed
> ArrayIndexOutOfBounds in BufferingWriter.java
> ---------------------------------------------
>
> Key: JENA-1919
> URL: https://issues.apache.org/jira/browse/JENA-1919
> Project: Apache Jena
> Issue Type: Bug
> Components: Base
> Affects Versions: Jena 3.15.0
> Reporter: Matt Hoffman
> Assignee: Andy Seaborne
> Priority: Major
> Fix For: Jena 3.16.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> 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.
>
> {code:java}
> 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);
> }
> {code}
> Which produces.
> {noformat}
> [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){noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)