United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6575586 : Cache: Unzipped cached files for gzip contents are still reported as gzip-encoded

Details
Type:
Bug
Submit Date:
2007-06-29
Status:
Closed
Updated Date:
2013-09-12
Project Name:
JDK
Resolved Date:
2011-10-12
Component:
deploy
OS:
generic,windows_xp
Sub-Component:
plugin
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6,6u24
Fixed Versions:
7u2 (b08)

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2 and windows 64-bit Vista

EXTRA RELEVANT SYSTEM CONFIGURATION :
java 1.6 (update 1 and update 2)


A DESCRIPTION OF THE PROBLEM :
Files that arrive from a gzipped stream are not cached in a gzip format but getContentEncoding() still reports 'gzip'

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Write an applet that fetches a file from a server that  sends it  gzip encoded.
Once the file is in the local cache although getContentEncoding will report 'gzip' the actual stream is not gzipped

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Regardless of whether the connection is coming from the server or the cache
I expect the stream to be gzipped
(or if it's not cached in the gzip fotmat I dont' expect the getContentEncoding to tell me that it is)
ACTUAL -
code works unless it is getting data from the cache

the getContentEncoding doesn't reflect the encoding of the cached data (I suspect it's storing the encoding details it received from the server but storing the files uncompressed)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Content-Encoding is gzip
java.io.IOException: Not in GZIP format
	at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
	at java.util.zip.GZIPInputStream.<init>(Unknown Source)
	at java.util.zip.GZIPInputStream.<init>(Unknown Source)
...

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
file must be grabbed from a server that will gzip the stream

...
   URL url=new URL(uri);
   connection = (HttpURLConnection)url.openConnection();

    connection.setDefaultUseCaches(true);
    connection.setRequestProperty("Accept-Encoding","gzip");
    connection.connect();
    httpResponseCode=connection.getResponseCode();
    System.out.println("Content-Encoding is "+connection.getContentEncoding());
 
   if(httpResponseCode==HttpURLConnection.HTTP_OK)
    {
     String gzip="gzip";
     if(gzip.equalsIgnoreCase(connection.getContentEncoding()))
     {
      // expecting a gziped stream
      buf=new DataInputStream(new BufferedInputStream(new GZIPInputStream(connection.getInputStream())));
     }
     else
     {
      System.out.println("stream not gzipped, Content-Encoding is "+connection.getContentEncoding());

      buf=new DataInputStream(new BufferedInputStream(connection.getInputStream()));
     }

     readBuffer(buf);
    ....
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
turn 'keep temporary files on my computer' off for 1.6 plugin

                                    

Comments
EVALUATION

Currently this bundle name is coming from property: 'ws.javaws.javadoc.bundle' which has the date part come from $BUNDLE_DATE env variable in Defs.gmk.   Maybe we need to use some different env variable commonly used for build date to be consistent.  This BUILD_DATE might have been set by some build process shell script.
                                     
2011-08-09
EVALUATION

The first time the gzip-content connection input stream are fetched it is gzipped.
The second time the connection accress return content from cached file which is already unzipped.
Since the transparent access to gzip-enabled sites is a nice feature, we must correct the cached URL connection provide to applets code such that it behaves and report consistently with respect to gzip encoded content.
                                     
2011-08-06



Hardware and Software, Engineered to Work Together