MCPcopy Create free account
hub / github.com/antlr/codebuff / getDone

Method getDone

output/java_guava/1.4.19/Futures.java:1178–1195  ·  view source on GitHub ↗

Returns the result of the input Future, which must have already completed. The benefits of this method are twofold. First, the name "getDone" suggests to readers that the Future is already done. Second, if buggy code calls getDone on a Future that is still pending

(Future<V> future)

Source from the content-addressed store, hash-verified

1176 */
1177
1178 @CanIgnoreReturnValue
1179 // TODO(cpovirk): Consider calling getDone() in our own code.
1180 public static <V> V getDone(Future<V> future)
1181 throws ExecutionException {
1182 /*
1183 * We throw IllegalStateException, since the call could succeed later. Perhaps we "should" throw
1184 * IllegalArgumentException, since the call could succeed with a different argument. Those
1185 * exceptions' docs suggest that either is acceptable. Google's Java Practices page recommends
1186 * IllegalArgumentException here, in part to keep its recommendation simple: Static methods
1187 * should throw IllegalStateException only when they use static state.
1188 *
1189 *
1190 * Why do we deviate here? The answer: We want for fluentFuture.getDone() to throw the same
1191 * exception as Futures.getDone(fluentFuture).
1192 */
1193 checkState(future.isDone(), "Future was expected to be done: %s", future);
1194 return getUninterruptibly(future);
1195 }
1196
1197 /**
1198 * Returns the result of {@link Future#get()}, converting most exceptions to a new instance of the

Callers 5

runMethod · 0.95
runMethod · 0.45
completeWithFutureMethod · 0.45
runMethod · 0.45
handleOneInputDoneMethod · 0.45

Calls 3

checkStateMethod · 0.45
isDoneMethod · 0.45
getUninterruptiblyMethod · 0.45

Tested by

no test coverage detected