提交 eccc227b 编写于 作者: K Kohsuke Kawaguchi

ensure we release all the background threads

上级 3a2def79
......@@ -118,9 +118,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
......@@ -229,7 +231,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
/**
* Remember {@link WebClient}s that are created, to release them properly.
*/
private List<WeakReference<WebClient>> clients = new ArrayList<WeakReference<WebClient>>();
private List<WebClient> clients = new ArrayList<WebClient>();
/**
* JavaScript "debugger" that provides you information about the JavaScript call stack
......@@ -336,11 +338,10 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
protected void tearDown() throws Exception {
try {
// cancel pending asynchronous operations, although this doesn't really seem to be working
for (WeakReference<WebClient> client : clients) {
WebClient c = client.get();
if(c==null) continue;
for (WebClient client : clients) {
// unload the page to cancel asynchronous operations
c.getPage("about:blank");
client.getPage("about:blank");
client.closeAllWindows();
}
clients.clear();
} finally {
......@@ -1414,7 +1415,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
// setJavaScriptEnabled(false);
setPageCreator(HudsonPageCreator.INSTANCE);
clients.add(new WeakReference<WebClient>(this));
clients.add(this);
// make ajax calls run as post-action for predictable behaviors that simplify debugging
setAjaxController(new AjaxController() {
public boolean processSynchron(HtmlPage page, WebRequestSettings settings, boolean async) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册