Commons Compress
  1. Commons Compress
  2. COMPRESS-29

Closing an CBZip2OutputStream when no data has been written fails with an java.lang.ArithmeticException: / by zero

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None

      Description

      The following test case reproduces the error:

      public class CBZip2OutputStreamTest extends TestCase {

      /**

      • @throws IOException
        */
        public void testEmtpyOutput() throws IOException { CBZip2OutputStream outputStream = new CBZip2OutputStream( new ByteArrayOutputStream() ); outputStream.close(); }

        }

      fails with:

      java.lang.ArithmeticException: / by zero
      at org.apache.tools.bzip2.CBZip2OutputStream.mainSort(CBZip2OutputStream.java:1174)
      at org.apache.tools.bzip2.CBZip2OutputStream.doReversibleTransformation(CBZip2OutputStream.java:1386)
      at org.apache.tools.bzip2.CBZip2OutputStream.endBlock(CBZip2OutputStream.java:476)
      at org.apache.tools.bzip2.CBZip2OutputStream.close(CBZip2OutputStream.java:427)
      at CBZip2OutputStreamTest.testEmtpyOutput(CBZip2OutputStreamTest.java:23)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      1. patch-update-bzip2.txt
        67 kB
        Christian Grobmeier

        Activity

        Torsten Curdt made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Stefan Bodewig made changes -
        Fix Version/s 1.0 [ 12313768 ]
        Dennis Lundberg made changes -
        Project Commons Sandbox [ 12310491 ] Commons Compress [ 12310904 ]
        Key SANDBOX-195 COMPRESS-29
        Component/s Compress [ 12311183 ]
        Torsten Curdt made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Torsten Curdt added a comment -

        should be fixed ... please verify and close

        Show
        Torsten Curdt added a comment - should be fixed ... please verify and close
        Torsten Curdt made changes -
        Assignee Torsten Curdt [ tcurdt ]
        Christian Grobmeier made changes -
        Field Original Value New Value
        Attachment patch-update-bzip2.txt [ 12397381 ]
        Hide
        Christian Grobmeier added a comment -

        The Ant implementation has been fixed for a while. The attached patch updates the bzip2 implementation to the current impl which is beeing used from Ant.

        Show
        Christian Grobmeier added a comment - The Ant implementation has been fixed for a while. The attached patch updates the bzip2 implementation to the current impl which is beeing used from Ant.
        Hide
        Emmanuel Bourg added a comment -

        The Ant class is also affected by this issue :

        https://issues.apache.org/bugzilla/show_bug.cgi?id=32200

        Show
        Emmanuel Bourg added a comment - The Ant class is also affected by this issue : https://issues.apache.org/bugzilla/show_bug.cgi?id=32200
        Stefan Liebig created issue -

          People

          • Assignee:
            Torsten Curdt
            Reporter:
            Stefan Liebig
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development