[RFC] Fix IndexOutOfBoundException because of corrupted entry in recently_used file
Thomas Meyer
thomas at m3y3r.de
Tue Apr 3 06:14:42 PDT 2012
Here you go:
# HG changeset patch
# User Thomas Meyer <thomas at m3y3r.de>
# Date 1333458674 -7200
# Node ID a195e919572bce5f585f0fa1b595540519920a63
# Parent f6540088f06f2d9962e1c5b7858c4212f045759e
Added Reproducer for corrupted cache entry file, containing an invalid path
diff -r f6540088f06f -r a195e919572b Makefile.am
--- a/Makefile.am Wed Mar 28 14:32:56 2012 +0200
+++ b/Makefile.am Tue Apr 03 15:11:14 2012 +0200
@@ -565,7 +565,7 @@
cd $(JNLP_TESTS_ENGINE_DIR) ; \
class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \
CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):. \
- $(BOOT_DIR)/bin/java -Dtest.server.dir=$(JNLP_TESTS_SERVER_DEPLOYDIR) -Djavaws.build.bin=$(DESTDIR)$(bindir)/javaws \
+ $(BOOT_DIR)/bin/java -Dtest.server.dir=$(JNLP_TESTS_SERVER_DEPLOYDIR) -Djavaws.build.bin=$(DESTDIR)$(bindir)/$(javaws) \
-Xbootclasspath:$(RUNTIME) CommandLine $$class_names \
> stdout.log 2> stderr.log ; \
cat stdout.log ; \
diff -r f6540088f06f -r a195e919572b tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java
--- a/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java Wed Mar 28 14:32:56 2012 +0200
+++ b/tests/jnlp_tests/signed/CacheReproducer/testcases/CacheReproducerTest.java Tue Apr 03 15:11:14 2012 +0200
@@ -148,7 +148,7 @@
@Test
public void coruptAndRunCache2() throws Exception {
- clearAndEvaluateCache();
+ clearAndEvaluateCache();
evaluateSimpleTest1OkCache(runSimpleTest1());
assertCacheIsNotEmpty();
breakCache1();
@@ -164,6 +164,24 @@
assertLruExceptionNOTappeared(pr2);
}
+ @Test
+ public void coruptAndRunCache3() throws Exception {
+ clearAndEvaluateCache();
+ evaluateSimpleTest1OkCache(runSimpleTest1());
+ assertCacheIsNotEmpty();
+ breakCache3();
+ ProcessResult pr = runSimpleTest1();
+ assertLruExceptionAppeared(pr);
+ evaluateSimpleTest1OkCache(pr);
+ ProcessResult pr3 = runSimpleTest1();
+ evaluateSimpleTest1OkCache(pr3);
+ assertLruExceptionNOTappeared(pr3);
+ clearAndEvaluateCache();
+ ProcessResult pr2 = runSimpleTest1();
+ evaluateSimpleTest1OkCache(pr2);
+ assertLruExceptionNOTappeared(pr2);
+ }
+
private void assertLruExceptionNOTappeared(ProcessResult pr2) {
Assert.assertFalse("serr should NOT contain " + lre, pr2.stderr.contains(lre));
}
@@ -174,7 +192,7 @@
@Test
public void coruptAndRunCache1Signed() throws Exception {
- clearAndEvaluateCache();
+ clearAndEvaluateCache();
evaluateSimpleTest1OkCache(runSimpleTest1());
assertCacheIsNotEmpty();
breakCache1();
@@ -189,7 +207,7 @@
@Test
public void coruptAndRunCache2Signed() throws Exception {
- clearAndEvaluateCache();
+ clearAndEvaluateCache();
evaluateSimpleTest1OkCache(runSimpleTest1());
assertCacheIsNotEmpty();
breakCache1();
@@ -236,7 +254,7 @@
}
- //next four tests are designed to ensure, that corupted cache wil not break already loaded cached files
+ //next four tests are designed to ensure, that corrupted cache will not break already loaded cached files
public static final String CR1 = "CacheReproducer1";
public static final String CR2 = "CacheReproducer2";
public static final String CR11 = "CacheReproducer1_1";
@@ -378,6 +396,14 @@
return s;
}
+ private static String breakLastPath(String s) {
+ int i = s.lastIndexOf(home);
+ if(i >= 0 && i <= s.length() && home.length() > 4)
+ return s.substring(0, i + 3);
+
+ return null;
+ }
+
private static void breakCache1() throws IOException {
String s = loadCacheFile();
s = breakAll(s);
@@ -390,6 +416,12 @@
ServerAccess.saveFile(s, icedteaCacheFile);
}
+ private static void breakCache3() throws IOException {
+ String s = loadCacheFile();
+ s = breakLastPath(s);
+ ServerAccess.saveFile(s, icedteaCacheFile);
+ }
+
private static ServerAccess.ProcessResult runSimpleTest1() throws Exception {
return runSimpleTest1(null, "simpletest1");
}
More information about the distro-pkg-dev
mailing list