Commons IO
  1. Commons IO
  2. IO-302

ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: Streams/Writers
    • Labels:
      None
    • Environment:

      Win7 64bit, Java 6 32bit

      Description

      Resetting the BOMInputStream doesn't reset the fbLength member variable. This causes fbLength to grow bigger than the firstBytes array (when the file doesn't contain a BOM), which leads to an ArrayIndexOutOfBoundsException in the readFirstBytes method.

      The attached test case reveals the problem.

      1. IO-302.patch
        2 kB
        Marcos Vinícius da Silva
      2. testfileNoBOM.xml
        6 kB
        Jan Steuerwald
      3. testfileBOM.xml
        6 kB
        Jan Steuerwald
      4. Test.java
        2 kB
        Jan Steuerwald

        Activity

        Hide
        Gary Gregory added a comment -

        Could post this as a unit test patch file with a license grant to Apache (this can be done by selecting the check-box when you attach a file). Supplying the test files will help too. Thank you!

        Show
        Gary Gregory added a comment - Could post this as a unit test patch file with a license grant to Apache (this can be done by selecting the check-box when you attach a file). Supplying the test files will help too. Thank you!
        Hide
        Marcos Vinícius da Silva added a comment -

        Hi all!
        Please, take a look for this correction.
        I cleaned up the test case to make it more clear and cut the sample file.

        Show
        Marcos Vinícius da Silva added a comment - Hi all! Please, take a look for this correction. I cleaned up the test case to make it more clear and cut the sample file.
        Hide
        Gary Gregory added a comment -

        In SVN.

        Show
        Gary Gregory added a comment - In SVN.
        Hide
        Gary Gregory added a comment -

        Version 2.2 has been released and addresses this issue.

        Show
        Gary Gregory added a comment - Version 2.2 has been released and addresses this issue.

          People

          • Assignee:
            Gary Gregory
            Reporter:
            Jan Steuerwald
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development