JDK-6575586 : Cache: Unzipped cached files for gzip contents are still reported as gzip-encoded
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6,6u24
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2007-06-29
  • Updated: 2013-09-12
  • Resolved: 2011-10-12
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 Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u2 b08Fixed 8Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
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.
09-08-2011

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.
06-08-2011