Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1919

ArrayIndexOutOfBounds in BufferingWriter.java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 3.15.0
    • Jena 3.16.0
    • Base
    • 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)

      Attachments

        Activity

          People

            andy Andy Seaborne
            Hoffman Matt Hoffman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m