Uploaded image for project: '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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 1.0
    • None
    • 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)

      Attachments

        1. patch-update-bzip2.txt
          67 kB
          cgrobmeier

        Activity

          People

            tcurdt Torsten Curdt
            stefan liebig Stefan Liebig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: