/** * Wait forever for waitable to finish. Periodically reports progress. * * @param waitable Waitable which we wait for * @param progressable Progressable for reporting progress (Job context) * @param msecsPeriod How often to report progress * @param <T> Result type * @return Result of waitable */ private static <T> T waitForever(Waitable<T> waitable, Progressable progressable, int msecsPeriod) { while (true) { waitFor(waitable, progressable, msecsPeriod, msecsPeriod); if (waitable.isFinished()) { try { return waitable.getResult(); } catch (ExecutionException e) { throw new IllegalStateException("waitForever: " + "ExecutionException occurred while waiting for " + waitable, e); } catch (InterruptedException e) { throw new IllegalStateException("waitForever: " + "InterruptedException occurred while waiting for " + waitable, e); } } } }