diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 6689f974466c..9231c7986056 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -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() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index 9bce3bcbb4f5..4af6a5be67d1 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -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();