debug tests hanging in ChangeListManagerImpl.waitEverythingDoneInTestMode

This commit is contained in:
peter
2018-07-10 07:03:44 +02:00
parent 9ab5f5566b
commit 2a9bcf1d96
2 changed files with 16 additions and 5 deletions
@@ -2396,16 +2396,23 @@ public class UIUtil {
/** @see #pump() */
@TestOnly
public static void dispatchAllInvocationEvents() {
//noinspection StatementWithEmptyBody
while(dispatchInvocationEvent());
for (int i = 1; ; i++) {
AWTEvent event = dispatchInvocationEvent();
if (event == null) break;
if (i % 10000 == 0) {
//noinspection UseOfSystemOutOrSystemErr
System.out.println("Suspiciously many (" + i + ") AWT events, last dispatched " + event);
}
}
}
@TestOnly
public static boolean dispatchInvocationEvent() {
public static AWTEvent dispatchInvocationEvent() {
assert EdtInvocationManager.getInstance().isEventDispatchThread() : Thread.currentThread() + "; EDT: "+getEventQueueThread();
final EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
AWTEvent event = eventQueue.peekEvent();
if (event == null) return false;
if (event == null) return null;
try {
event = eventQueue.getNextEvent();
if (event instanceof InvocationEvent) {
@@ -2418,7 +2425,7 @@ public class UIUtil {
catch (Exception e) {
LOG.error(e);
}
return true;
return event;
}
private static Thread getEventQueueThread() {
@@ -1716,7 +1716,11 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
@TestOnly
private void awaitAll() {
long start = System.currentTimeMillis();
while (true) {
if (System.currentTimeMillis() - start > TimeUnit.MINUTES.toMillis(10)) {
throw new IllegalStateException("Too long waiting for VCS update");
}
Future future;
synchronized (myFutures) {
future = myFutures.peek();