mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
JENKINS-8698 HudsonTestCase sometimes fails with NPE in tearDown() while trying to free htmlunit resources
Not really sure what is happening, but I don't think the build should fail here. So let's try to be more resiliant (try twice loading the page) and don't fail if the exception occurs again.
This commit is contained in:
1 parent
4077b5da1c
commit
a70f6b19ae
1 file changed
+11
-1
@@ -294,7 +294,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
|
||||
WebClient c = client.get();
|
||||
if(c==null) continue;
|
||||
// unload the page to cancel asynchronous operations
|
||||
c.getPage("about:blank");
|
||||
safeUnloadPage(c, 2);
|
||||
}
|
||||
clients.clear();
|
||||
} finally {
|
||||
@@ -315,6 +315,16 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void safeUnloadPage(WebClient c, int maxTries) {
|
||||
if (maxTries == 0) return;
|
||||
try{
|
||||
c.getPage("about:blank");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
safeUnloadPage(c, maxTries--);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
System.out.println("=== Starting "+ getClass().getSimpleName() + "." + getName());
|
||||
|
||||
Reference in new issue
Block a user