Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8276305

Infinite loop in ZipOutputStream.close()

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Since the existing behavior of close/finish/closeEntry methods keep deflater in undefined state during exception scenario , these changes should not affect any of the existing behavior with streams.
    • Interface Kind:
      Other
    • Scope:
      Implementation

      Description

      Summary

      If the underlying OutputStream associated with ZipOutputStream or GZIPOutputStream throws an IOException while the zip stream is being closed, the associated compressor is left in an inconsistent state and may cause infinite looping.

      Problem

      If a call to GZIPOutputStream.close(), GZIPOutputStream.finish() or ZipOutputStream.closeEntry() results in an IOException, an call to GZIPOutputStream.write() or ZipOutputStream.write() may result in an infinite loop.

      Solution

      If an IOException is encountered while using the default JDK compressor in GZIPOutputStream.finish() or ZipOutputStream.closeEntry(), then close the compressor before propagating that Exception up the stack. DeflaterOutputStream.close() is hardened to ensure that the default JDK compressor is closed in case where Throwable is propagated up the stack. This will ensure that subsequent write operations using the same deflater will fail. An exception is made for the ZipOutputStream.closeEntry() call. For that method, IOExceptions of type ZipException will not cause the associated compressor to be closed.

      Harden DeflaterOutputStream.close() to close out the associated default JDK compressor before propagating a Throwable (if any) up the stack

      Harden ZIPOutputStream.closeEntry() to close out the associated default JDK compressor before propagating an IOException, not of type ZipException, (if any) up the stack

      Harden GZIPOutputStream.finish() to close out the associated default JDK compressor before propagating an IOException (if any) up the stack

      The behavioral change will be documented in a release note.

      Specification

      A future CSR may propose spec clarifications.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rreddy Ravi Reddy
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Alan Bateman, Lance Andersen, Sean Coffey
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: