Fixed the cascade of the "2nd instance" problem.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23557 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2009-11-07 00:55:46 +00:00
1 parent ebfa6a0e2d
commit 05c93bf637
1 file changed
+9 -1
@@ -225,7 +225,15 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
AbstractProject.WORKSPACE.toString();
hudson = newHudson();
try {
hudson = newHudson();
} catch (Exception e) {
// if Hudson instance fails to initialize, it leaves the instance field non-empty and break all the rest of the tests, so clean that up.
Field f = Hudson.class.getDeclaredField("theInstance");
f.setAccessible(true);
f.set(null,null);
throw e;
}
hudson.setNoUsageStatistics(true); // collecting usage stats from tests are pointless.
hudson.setCrumbIssuer(new TestCrumbIssuer());