Uploaded image for project: 'ShrinkWrap'
  1. ShrinkWrap
  2. SHRINKWRAP-407

Archive.toString might throw java.lang.IndexOutOfBoundsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.1.0-alpha-3
    • 1.1.0-alpha-2
    • impl-base
    • None

      In some cases when outputting archive contents via the Archive.toString(Formatter) method, I get a java.lang.IndexOutOfBoundsException when writing to the output stream. After some investigation I found the cause being an erroneous calculation in the buffered write.

      The error can be reproduced with the following test case added to ArchiveWriteToTestCase in impl-base:

       
      @Test
      public void shouldBufferWritesCorrectly() throws IOException {
          MockOutputStream outputStream = new MockOutputStream();
          byte[] content = new byte[9202];
          for (int i = 0; i < content.length; i++) {
              content[i] = (i + "").getBytes()[0];
          }
          IOUtil.bufferedWriteWithFlush(outputStream, content);
          Assert.assertArrayEquals("Inconsistent writes?", content, outputStream.getContents());
      }
      

              tommysdk Tommy Tynjä (Inactive)
              tommysdk Tommy Tynjä (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: