Java Duration Calculate getOrThrow(final ListenableFuture Future, final Duration timeout)

Here you can find the source of getOrThrow(final ListenableFuture Future, final Duration timeout)

Description

get Or Throw

License

Apache License

Declaration

private static <T> T getOrThrow(final ListenableFuture<T> Future, final Duration timeout) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import com.google.common.base.Throwables;

import com.google.common.util.concurrent.ListenableFuture;

import java.time.Duration;

import java.util.concurrent.ExecutionException;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class Main {
    private static <T> T getOrThrow(final ListenableFuture<T> Future, final Duration timeout) {
        try {/*from  ww w.  j  a v a  2s.c  o  m*/
            return Future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            throw Throwables.propagate(e);
        }
    }
}

Related

  1. failAfter(Duration duration)
  2. futureWithTimeout(Duration timeout, ScheduledExecutorService executorService)
  3. getDurationAsISO8601(Duration duration)
  4. getDurationByTimeValues(final long hours, final long minutes, final long seconds)
  5. getExpirationMillis(long now, Duration duration)
  6. getTTLSeconds(Duration duration)
  7. isDuration(String value)
  8. isFinite(Duration duration)
  9. isInfPositive(Duration duration)