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

GZIPOutputStream doesn't support optional GZIP fields

XMLWordPrintable

    • Fix Understood
    • x86
    • windows_xp



      Name: rmT116609 Date: 07/15/2003


      A DESCRIPTION OF THE REQUEST :
      The GZIP format has options for extra fields and comments at the front, which are turned on via bits in the GZIP header.

      Class GZIPOutputStream does not allow these bits to be set, or extra fields to be written. (In contrast, GZIPInputStream will properly skip these extra fields when they are present.)

      The most straightforward workaround would be to create a more-fully-featured subclass of GZIPOutputStream which overrides writeHeader() to allow writing these extra fields.

      Unfortunately, GZIPOutputStream.writeHeader() is private, and so cannot be overridden. The constructor can be overridden, but that would require copying a lot of initialization down from superclasses.

      It'd be ideal if explicit support for using these extra GZIP capabilities could be added to GZIPOutputStream. These capabilites are seldom used, but are part of the GZIP spec, and my project happens to need them for compatibility with 100+TB of data written with EXTRA header info from legacy C++ code. .

      Alternatively, a little refactoring could make it much easier for developers to cleanly extend GZIPOutputStream. (writeHeader() could be made protected, or the in-constructor call to writeHeader() could be moved out to a overridable setup method. )

      JUSTIFICATION :
      These capabilites are seldom used, but are part of the GZIP spec, and some applications need them.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      GZIPOutputStream offers protocols for using these GZIP format features, or lets them be added to a subclass more easily.
      ACTUAL -
      GZIPOutputStream makes it hard to write a header with these extra features.

      CUSTOMER SUBMITTED WORKAROUND :
      It looks like it will be possible to copy down the initialization code from the GZIPOutputStream, DeflaterOutputStream, and FilterOutputStream constructors -- all the affected object fields are protected -- and replace the writeHeader() with a version that writes a GZIP header with additional options.

      It also would be possible to hijack GZIPOutputStream's header in the wrapped stream, discarding it and writing a different header instead, but that seems a bit more awkward.
      (Incident Review ID: 188778)
      ======================================================================

            lzang Lin Zang
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: