@Override public final boolean isDone() { return super.isDone(); }
@Override public final boolean isDone() { return super.isDone(); }
@Override public final boolean isDone() { return super.isDone(); }
@Override public String toString() { StringBuilder builder = new StringBuilder().append(super.toString()).append("[status="); if (isCancelled()) { builder.append("CANCELLED"); } else if (isDone()) { addDoneString(builder); } else { String pendingDescription; try { pendingDescription = pendingToString(); } catch (RuntimeException e) { // Don't call getMessage or toString() on the exception, in case the exception thrown by the // subclass is implemented with bugs similar to the subclass. pendingDescription = "Exception thrown from implementation: " + e.getClass(); } // The future may complete during or before the call to getPendingToString, so we use null // as a signal that we should try checking if the future is done again. if (pendingDescription != null && !pendingDescription.isEmpty()) { builder.append("PENDING, info=[").append(pendingDescription).append("]"); } else if (isDone()) { addDoneString(builder); } else { builder.append("PENDING"); } } return builder.append("]").toString(); }
@Override public boolean isDone() { callAsyncGet(0, TimeUnit.MILLISECONDS); return super.isDone(); } }
@Override public void run() { future.set("success"); if (!future.isDone()) { errorMessage.set("Set call exited before future was complete."); } } });
@Override public void run() { future.setException(new IllegalArgumentException("failure")); if (!future.isDone()) { errorMessage.set("SetException call exited before future was complete."); } } });
@Override public void run() { future.cancel(true); if (!future.isDone()) { errorMessage.set("Cancel call exited before future was complete."); } } });
@Override public String toString() { StringBuilder builder = new StringBuilder().append(super.toString()).append("[status="); if (isCancelled()) { builder.append("CANCELLED"); } else if (isDone()) { addDoneString(builder); } else { String pendingDescription; try { pendingDescription = pendingToString(); } catch (RuntimeException e) { // Don't call getMessage or toString() on the exception, in case the exception thrown by the // subclass is implemented with bugs similar to the subclass. pendingDescription = "Exception thrown from implementation: " + e.getClass(); } // The future may complete during or before the call to getPendingToString, so we use null // as a signal that we should try checking if the future is done again. if (!isNullOrEmpty(pendingDescription)) { builder.append("PENDING, info=[").append(pendingDescription).append("]"); } else if (isDone()) { addDoneString(builder); } else { builder.append("PENDING"); } } return builder.append("]").toString(); }
if (!isDone()) { Listener oldHead = listeners; if (oldHead != Listener.TOMBSTONE) {
@Override public String toString() { StringBuilder builder = new StringBuilder().append(super.toString()).append("[status="); if (isCancelled()) { builder.append("CANCELLED"); } else if (isDone()) { addDoneString(builder); } else { String pendingDescription; try { pendingDescription = pendingToString(); } catch (RuntimeException e) { // Don't call getMessage or toString() on the exception, in case the exception thrown by the // subclass is implemented with bugs similar to the subclass. pendingDescription = "Exception thrown from implementation: " + e.getClass(); } // The future may complete during or before the call to getPendingToString, so we use null // as a signal that we should try checking if the future is done again. if (!isNullOrEmpty(pendingDescription)) { builder.append("PENDING, info=[").append(pendingDescription).append("]"); } else if (isDone()) { addDoneString(builder); } else { builder.append("PENDING"); } } return builder.append("]").toString(); }
if (isDone()) { throw new TimeoutException(message + " but future completed as timeout expired");
public void testGetFailure_NotCompleted() { AbstractFuture<String> future = new AbstractFuture<String>() {}; assertThat(future.isDone()).isFalse(); assertThat(future.tryInternalFastPathGetFailure()).isNull(); }
private static void assertDone(AbstractFuture<Integer> future) { CountingRunnable listener = new CountingRunnable(); future.addListener(listener, directExecutor()); listener.assertRun(); assertThat(future.isDone()).isTrue(); assertCannotSet(future); assertCannotCancel(future); }
private static void assertPending(AbstractFuture<Integer> future) { assertThat(future.isDone()).isFalse(); assertThat(future.isCancelled()).isFalse(); CountingRunnable listener = new CountingRunnable(); future.addListener(listener, directExecutor()); listener.assertNotRun(); verifyGetOnPendingFuture(future); verifyTimedGetOnPendingFuture(future); }
public void testEvilFuture_setFuture() throws Exception { final RuntimeException exception = new RuntimeException("you didn't say the magic word!"); AbstractFuture<String> evilFuture = new AbstractFuture<String>() { @Override public void addListener(Runnable r, Executor e) { throw exception; } }; AbstractFuture<String> normalFuture = new AbstractFuture<String>() {}; normalFuture.setFuture(evilFuture); assertTrue(normalFuture.isDone()); try { normalFuture.get(); fail(); } catch (ExecutionException e) { assertThat(e).hasCauseThat().isSameAs(exception); } }
assertThat(future.isDone()).isTrue();
assertThat(future.isDone()).isTrue();
assertThat(future.isDone()).isTrue();
public void testCancel_done() throws Exception { AbstractFuture<String> future = new AbstractFuture<String>() { { set("foo"); } }; assertFalse(future.cancel(true)); assertFalse(future.isCancelled()); assertTrue(future.isDone()); }