void (Predicate<? super CompletionPhase> condition) { for (int j = 1; j < 1000; j++) { // in EDT to avoid getting the phase in the middle of a complex EDT operation that changes the phase several times CompletionPhase phase = EdtTestUtil.runInEdtAndGet(() -> CompletionServiceImpl.getCompletionPhase()); if (condition.test(phase)) { return; } if (j >= 400 && j % 100 == 0) { System.out.println("Free memory: " + Runtime.getRuntime().freeMemory() + " of " + Runtime.getRuntime().totalMemory() + "\n"); ThreadUtil.printThreadDump(); System.out.println("\n\n----------------------------\n\n"); } TimeoutUtil.sleep(10); } TestCase.fail("Too long completion: " + CompletionServiceImpl.getCompletionPhase()); }