From 05c93bf637beddbb6f069572613e057a671028a5 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 7 Nov 2009 00:55:46 +0000 Subject: [PATCH] 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 --- .../java/org/jvnet/hudson/test/HudsonTestCase.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index ffa6621f88..2948e2831b 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -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());