[RFC] Fix IndexOutOfBoundException because of corrupted entry in recently_used file
Thomas Meyer
thomas at m3y3r.de
Mon Apr 9 15:04:35 PDT 2012
Am Freitag, den 06.04.2012, 12:01 +0200 schrieb Jiri Vanek:
+ /**
+ * This is breaking paths in second part of cache file item
+ * @throws Exception
+ */
+ @Test
+ public void coruptAndRunCache3() throws Exception {
+ clearAndEvaluateCache();
+ evaluateSimpleTest1OkCache(runSimpleTest1());
+ assertCacheIsNotEmpty();
+ breakCache3();
+ ProcessResult pr = runSimpleTest1();
+ assertAoobNOTappeared(pr);
In the current code the StringIndexOutOfBoundsExceptions is only printed
in verbose mode in netx/net/sourceforge/jnlp/cache/ResourceTracker.java
in the private class Downloader in this catch:
try {
// Resource processing involves writing to files
// (cache entry trackers, the files themselves, etc.)
// and it therefore needs to be privileged
final Resource fResource = resource;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
processResource(fResource);
return null;
}
});
} catch (Exception ex) {
if (JNLPRuntime.isDebug())
-> ex.printStackTrace();
}
the Exception itself is thrown at CacheUtil.getCacheFileIfExist() -> pathToURLPath()
private static String pathToURLPath(String path) {
int len = cacheDir.length();
int index = path.indexOf(File.separatorChar, len + 1);
-> return path.substring(index);
}
+ assertLruExceptionAppeared(pr);
+ evaluateSimpleTest1OkCache(pr);
+ ProcessResult pr3 = runSimpleTest1();
+ evaluateSimpleTest1OkCache(pr3);
+ assertLruExceptionNOTappeared(pr3);
+ clearAndEvaluateCache();
+ ProcessResult pr2 = runSimpleTest1();
+ evaluateSimpleTest1OkCache(pr2);
+ assertLruExceptionNOTappeared(pr2);
+ }
I'm not sure if this test case does the right thing.
kind regards
thomas
More information about the distro-pkg-dev
mailing list