Hello Guest

[FIXED] Files cache was corrupted and applet never started again

  • 2 Replies
  • 4617 Views
Dunno how exactly happened but I was refreshing some page, testing something about the html content and suddenly the applet inside stopped to run, when I take a look at the Java console, it failed to read the cache, an exception related with the ObjectInputStream serialization. I tried to refresh the page and it always failed when reading the cache file. I removed the cache file from lwjgl cache and it worked.

To test the bug, open the lwjglcache, the application you want, and introduce some noise to the cache file, then try to run the application again.

In other words, it could happen that the cache file be corrupted then the applet will never work again, I propose to catch the exception when reading the cache and consider it as it doesn't exist:

Code: [Select]
protected HashMap<String, Long> readCacheFile(File file) throws Exception {
FileInputStream fis = new FileInputStream(file);
try {
ObjectInputStream dis = new ObjectInputStream(fis);
HashMap<String, Long> hashMap = (HashMap<String, Long>) dis.readObject();
dis.close();
return hashMap;
} catch (Exception e) {
// failed dunno why, could be StreamCorruptedException, IOException, etc
} finally {
fis.close();
}
// in case it fails, return an empty map
return new HashMap<String, Long>();
}

note: I have no tested that code, it is only a suggestion.

*

Offline kappa

  • *****
  • 1313
Re: [BUG] Files cache was corrupted and applet never started again
« Reply #1 on: March 07, 2011, 19:23:50 »
ah nice find (once again), will try patch later on today.

*

Offline kappa

  • *****
  • 1313
Re: [BUG] Files cache was corrupted and applet never started again
« Reply #2 on: March 07, 2011, 22:39:47 »
ok the patch is applied.

Thanks again for the recent stream of patches, tis brilliant stuff.