in client-http/src/main/java/org/apache/livy/client/http/JobHandleImpl.java [173:201]
private T get(boolean waitIndefinitely, long timeout, TimeUnit unit)
throws ExecutionException, InterruptedException, TimeoutException {
if (!isDone) {
synchronized (lock) {
if (waitIndefinitely) {
while (!isDone) {
lock.wait();
}
} else {
long now = System.nanoTime();
long deadline = now + unit.toNanos(timeout);
while (!isDone && deadline > now) {
lock.wait(TimeUnit.NANOSECONDS.toMillis(deadline - now));
now = System.nanoTime();
}
if (!isDone) {
throw new TimeoutException();
}
}
}
}
if (isCancelled) {
throw new CancellationException();
}
if (error != null) {
throw new ExecutionException(error);
}
return result;
}