Clean shared state pollution to avoid flaky tests.

This commit is contained in:
Yang Chen 2021-08-19 11:38:08 +08:00
parent f2e2140b57
commit 3a1d467f1d
2 changed files with 6 additions and 0 deletions

View File

@ -243,6 +243,11 @@ public class TaskMonitor {
}
}
public synchronized void purgeAllTasks() {
tasks.clear();
rpcTasks.clear();
}
/**
* This class encapsulates an object as well as a weak reference to a proxy
* that passes through calls to that object. In art form:

View File

@ -142,6 +142,7 @@ public class TestTaskMonitor {
}
assertEquals("RPC Tasks have been purged!", RPCTaskNums, remainRPCTask);
tm.shutdown();
tm.purgeAllTasks();
}
@Test