United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4813885 : RFE: GZIPOutputStream should implement flush using Z_SYNC_FLUSH

Details
Type:
Enhancement
Submit Date:
2003-02-06
Status:
Closed
Updated Date:
2010-06-09
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
core-libs
OS:
linux,generic
Sub-Component:
java.util.jar
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.1,6,6u19
Fixed Versions:

Related Reports
Relates:
Relates:

Sub Tasks

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



Hardware and Software, Engineered to Work Together