void (@NotNull String message, long expected, int attempts, @NotNull Runnable actionToMeasure) { while (true) { attempts--; waitForAllBackgroundActivityToCalmDown(); long duration = TimeoutUtil.measureExecutionTime(actionToMeasure::run); try { assertTiming(message, expected, duration); break; } catch (AssertionFailedError e) { if (attempts == 0) throw e; System.gc(); System.gc(); System.gc(); String s = e.getMessage() + "\n " + attempts + " " + StringUtil.pluralize("attempt", attempts) + " remain"; TeamCityLogger.warning(s, null); System.err.println(s); } } }