JDK-6697988 : Applet cache fails on non-zip files
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-05-06
  • Updated: 2012-12-05
  • Resolved: 2012-12-05
Description
FULL PRODUCT VERSION :
java version "1.6.0_10-ea"
Java(TM) SE Runtime Environment (build 1.6.0_10-ea-b12)
Java HotSpot(TM) Client VM (build 11.0-b11, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Files downloaded from HttpURLConnection with a wrong content-type will make the downloadResourceToCache method fail.
Specifically I am downloading an lzma encoded jar file which gives the following exception:
java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(Unknown Source)
	at java.util.jar.JarFile.<init>(Unknown Source)
	at java.util.jar.JarFile.<init>(Unknown Source)
	at com.sun.deploy.cache.CacheEntry.writeFileToDisk(Unknown Source)
	at com.sun.deploy.cache.Cache$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source)
	at com.sun.deploy.cache.DeployFileOutputStream.close(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(Unknown Source)
	at org.lwjgl.util.applet.AppletLoader.downloadJars(AppletLoader.java:755)
	at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:584)
	at java.lang.Thread.run(Unknown Source)

The specific error is because the server is reporting that the file is of type application/java-archive - which is wrong. The correct mime is application/x-lzma. Adding an .htaccess file with the following content fixed the issue:
AddType application/x-lzma .lzma

However the cache thingy should handle this case gracefully.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
download an lzma encoded fle (or any non-zip files?) with a content-type of application/java-archive.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
cache updated correctly
ACTUAL -
java.util.zip.ZipException: error in opening zip file

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
add .htaccess file with a line containing:
AddType application/x-lzma .lzma

Comments
Minor case where download does not nicely handle resource server reporting wrong mime-type.
05-12-2012