List of usage examples for com.google.common.util.concurrent Futures withFallback
@Deprecated @CheckReturnValue public static <V> ListenableFuture<V> withFallback(ListenableFuture<? extends V> input, FutureFallback<? extends V> fallback)
From source file:com.spotify.helios.testing.HeliosSoloDeployment.java
private <T> T getOrNull(final ListenableFuture<T> future) throws ExecutionException, InterruptedException { return Futures.withFallback(future, new FutureFallback<T>() { @Override/*w w w . j av a 2s.c o m*/ public ListenableFuture<T> create(@NotNull final Throwable t) throws Exception { return Futures.immediateFuture(null); } }).get(); }
From source file:org.rhq.enterprise.server.cloud.StorageNodeManagerBean.java
private ListenableFuture<StorageNodeLoadComposite> wrapFuture(ListenableFuture<StorageNodeLoadComposite> future, final StorageNodeLoadComposite value, final String msg) { return Futures.withFallback(future, new FutureFallback<StorageNodeLoadComposite>() { @Override/* w w w . j a va2 s . c o m*/ public ListenableFuture<StorageNodeLoadComposite> create(Throwable t) throws Exception { if (log.isDebugEnabled()) { log.debug(msg, t); } else { log.info(msg + ": " + t.getMessage()); } return Futures.immediateFuture(value); } }); }
From source file:com.spotify.helios.system.SystemTestBase.java
protected <T> T getOrNull(final ListenableFuture<T> future) throws ExecutionException, InterruptedException { return Futures.withFallback(future, new FutureFallback<T>() { @Override//ww w.ja v a 2s .c om public ListenableFuture<T> create(@NotNull final Throwable t) throws Exception { return Futures.immediateFuture(null); } }).get(); }