JDK-4813885 : RFE: GZIPOutputStream should implement flush using Z_SYNC_FLUSH
  • Type: Enhancement
  • Status: Closed
  • Resolution: Fixed
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P3
  • Affected Version: 1.4.1,6,6u19
  • OS: generic,linux
  • CPU: generic,x86
  • Submit Date: 2003-02-06
  • Updated Date: 2017-05-16
  • Resolved Date: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 7
7 b97Fixed
Related Reports
Relates :  
Relates :  
Description
Name: rmT116609			Date: 02/05/2003


DESCRIPTION OF THE PROBLEM :
If using GZIP'ed streams to compress network traffic, after writing a request, the compressed data so far has to be flushed to the server. This should be done in a way that does not looses the complete compression dictionary. The zlib library underlying the java.util.zip package provides a flush method Z_SYNC_FLUSH for this kind of stream synchronization. But the JNI implementation of the JDK only uses Z_FINISH which completely reset the dictionary or Z_NO_FLUSH.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I expect a way to synchronize/flush a GZIP'ed stream with its decompressor without loosing the complete compression dictionary.


(Review ID: 166846) 
======================================================================
CAP member reported this issue again and would like have it address if possibel -

Workaround usually works, however, if no more bytes happen to be output 
after this is called (and this is used in cases of dynamic output) then
sometimes an extra null(0) byte will appear at the end of the uncompressed output.
which is clearly unacceptable.

The lack of this functionality and lack of a reliable workaround are conspiring
to cause us no end of trouble here. GzipOutputStream.flush() should do a real zlib
flush. The community hasa been waiting over 10 years for this simple work.

Comments
EVALUATION Add new constructors GZIPOutputStream(..., boolean syncFlush) to use the newly added sync_flush mode (in Deflater class) for flush() invocation.
2010-05-17

EVALUATION Description is correct. src/share/native/java/util/zip/Deflator.c only uses Z_FINISH. This appears to be the case at least back to 1.2. -- iag@sfbay 2003-02-06
2003-02-06