Commons Compress
  1. Commons Compress
  2. COMPRESS-253

BZip2CompressorInputStream reads fewer bytes from truncated file than CPython's bz2 implementation

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.1, 1.6, 1.7
    • Fix Version/s: 1.8
    • Component/s: Compressors
    • Labels:

      Description

      Jython includes support for decompressing bz2 files using commons compress and shares regression tests with CPython. The CPython test test_read_truncated in test_bz2.py passes under CPython but fails under Jython.

      The BZip2CompressorInputStream is able to read 769 bytes from the truncated data rather than the 770 bytes that the CPython bz2 implementation can read.

      1. compress-253.patch
        12 kB
        Stefan Bodewig
      2. PythonTruncatedBzip2Test.java
        4 kB
        Indra Talip

        Activity

        Hide
        Indra Talip added a comment - - edited

        Attached file contains test cases translated to commons-compress/junit from the Jython/CPython regression tests for reading truncated files.

        Show
        Indra Talip added a comment - - edited Attached file contains test cases translated to commons-compress/junit from the Jython/CPython regression tests for reading truncated files.
        Hide
        Stefan Bodewig added a comment -

        The reason for this is that BZIp2CompressorInputStream always calculates the next byte when reading one.

        The attached patch (against current trunk) changes this and removes a piece of state at the same time. All existing tests inside Common Compress pass with the change but we are pretty close to release 1.7 and I don't feel well adding the change now without more extensive testing.

        Show
        Stefan Bodewig added a comment - The reason for this is that BZIp2CompressorInputStream always calculates the next byte when reading one. The attached patch (against current trunk) changes this and removes a piece of state at the same time. All existing tests inside Common Compress pass with the change but we are pretty close to release 1.7 and I don't feel well adding the change now without more extensive testing.
        Hide
        Indra Talip added a comment -

        With the patch applied to commons-compress all the Jython regression tests from commit b1304c8 on my fork of Jython for the bz2 module pass successfully. Thanks

        Show
        Indra Talip added a comment - With the patch applied to commons-compress all the Jython regression tests from commit b1304c8 on my fork of Jython for the bz2 module pass successfully. Thanks
        Hide
        Stefan Bodewig added a comment -

        fixed with svn revision 1559687

        Show
        Stefan Bodewig added a comment - fixed with svn revision 1559687

          People

          • Assignee:
            Unassigned
            Reporter:
            Indra Talip
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development