RFC: Netx - fix caching for compressed files

Omair Majid omajid at redhat.com
Wed Aug 5 08:28:04 PDT 2009


Hi,

When I added support for compression, I believe I accidentally broke 
caching of compressed files.

The way compression works is that Netx tells the server that it can 
accept the file encoded as pack200-gzip and gzip, when it asks for a 
file foo. In the case of compressed files, Netx saves the compressed 
file as foo.gz and then uncompress it as foo and goes on happily using 
it. When Netx is started next time, it tries to use the cached file foo. 
But first it checks that the cache is up to date by comparing the 
timestamps and the file sizes of the local file and the remote file. 
Because the remote file foo is compressed and the local file foo is 
uncompressed, the file sizes are very different. Netx decides that the 
file hasnt been cached, and redownloads the file.

The attached patch caches every downloaded file foo as foo.cache. It 
then processes (currently that's just uncompressing or copyting) 
foo.cache to generate foo. When it wants to check if the cache is up to 
date, it uses foo.cache as the local file instead of foo.

One potential issue is that we are now using up twice the disk space if 
the remote files arent compressed. However, this brings us the 
flexibility that the only code conditional on the file compression and 
names is the code that downloads the file.

ChangeLog
2009-08-05  Omair Majid  <omajid at redhat.com>

   * rt/net/sourceforge/jnlp/JNLPFile.java
   (openURL): Throw the cause of the original exception rather than just
   the message.
   * rt/net/sourceforge/jnlp/Launcher.java
   (launchApplication): Use getProcessedCacheFile.
   * rt/net/sourceforge/jnlp/cache/CacheEntry.java
   (CacheEntry): Use getOriginalCacheFile.
   (isCached): Likewise.
   * rt/net/sourceforge/jnlp/cache/CacheUtil.java
   (getReadPermission): Use getProcessedCacheFile.
   (getCacheFile): Renamed to...
   (getProcessedCacheFile): New function.
   (getOriginalCacheFile): New function.
   (getOutputStream): Renamed to.
   (getProcessedOutputStream): New function.
   (getOriginalOutputStream): New function.
   (getProcessedInputStream): Likewise.
   (getOriginalInputStream): Likewise.
   * rt/net/sourceforge/jnlp/cache/ResourceTracker.java
   (checkCache): Use getProcessedCacheFile for the local file name.
   (downloadResource): Always save file with a different file name, and
   uncompress or copy it to a file with the right name.
   (initializeResource): Use getProcessedCacheFile for the local file
   name.

Any comments?

Cheers,
Omair
-------------- next part --------------
A non-text attachment was scrubbed...
Name: netx-fix-caching.patch
Type: text/x-patch
Size: 14131 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20090805/5aadc868/netx-fix-caching.patch 


More information about the distro-pkg-dev mailing list