@Test public void canCancelReturnedFuture() { SettableFuture<Long> future = SettableFuture.create(); CoalescingSupplier<Long> supplier = new CoalescingSupplier<>(() -> Futures.getUnchecked(future)); ListenableFuture<Long> returned = supplier.getAsync(); returned.cancel(true); ListenableFuture<Long> after = supplier.getAsync(); future.set(1L); assertThat(Futures.getUnchecked(after)).isOne(); }
public ListenableFuture<T> getAsync() { return Futures.nonCancellationPropagating(getAsyncNotHandlingCancellation()); }
CoalescingSupplier implements Supplier<T> { public ListenableFuture<T> getAsync() { return Futures.nonCancellationPropagating(getAsyncNotHandlingCancellation()); } }
CoalescingSupplier implements Supplier<T> { public ListenableFuture<T> getAsync() { return Futures.nonCancellationPropagating(getAsyncNotHandlingCancellation()); } CoalescingSupplier(Supplier<T> delegate); }
CoalescingSupplier implements Supplier<T> { public ListenableFuture<T> getAsync() { return Futures.nonCancellationPropagating(getAsyncNotHandlingCancellation()); } CoalescingSupplier(Supplier<T> delegate); @Override T get(); ListenableFuture<T> getAsync(); }
CoalescingSupplier implements Supplier<T> { public ListenableFuture<T> getAsync() { return Futures.nonCancellationPropagating(getAsyncNotHandlingCancellation()); } CoalescingSupplier(Supplier<T> delegate); @Override T get(); ListenableFuture<T> getAsync();  }