Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-6799

GzipCodec/CompressionOutputStream resetState() fails to reset gzip header and CRC

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 0.21.0
    • None
    • io
    • None
    • Linux/x86-32, Java 1.6.0_15

    Description

      CompressionCodec gzip = new GzipCodec();
      Path fnHDFS = new Path(workDir, "concat" + gzip.getDefaultExtension());
      OutputStream out = localFs.create(fnHDFS);
      Compressor gzCmp = gzip.createCompressor();
      CompressionOutputStream gzOStm = gzip.createOutputStream(out, gzCmp);

      gzOStm.write("first gzip concat\n member\nwith three lines\n".getBytes());
      gzOStm.finish();
      gzOStm.resetState();
      gzOStm.write("2nd gzip concat member\n".getBytes());
      gzOStm.finish();
      gzOStm.resetState();
      gzOStm.write("gzip concat\nmember #3\n".getBytes());
      gzOStm.close();

      This should create a 3-member concatenated gzip file (i.e., equivalent to concatenation of three individual gzip files). However, resetState() simply resets the underlying deflate engine; it does not reset the running CRC-32, nor does it set a flag to write a new gzip header. As a result, the output stream is corrupted--i.e., only the first member is readable.

      I also have hex dumps, but they don't work well with proportional fonts.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              roelofs Greg Roelofs
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: