in integration/kotlinx-coroutines-guava/src/ListenableFuture.kt [393:411]
override fun isCancelled(): Boolean {
// This expression ensures that isCancelled() will *never* return true when isDone() returns false.
// In the case that the deferred has completed with cancellation, completing `this`, its
// reaching the "cancelled" state with a cause of CancellationException is treated as the
// same thing as auxFuture getting cancelled. If the Job is in the "cancelling" state and
// this Future hasn't itself been successfully cancelled, the Future will return
// isCancelled() == false. This is the only discovered way to reconcile the two different
// cancellation contracts.
return auxFuture.isCancelled || isDone && !auxFutureIsFailed && try {
Uninterruptibles.getUninterruptibly(auxFuture) is Cancelled
} catch (e: CancellationException) {
// `auxFuture` got cancelled right after `auxFuture.isCancelled` returned false.
true
} catch (e: ExecutionException) {
// `auxFutureIsFailed` hasn't been updated yet.
auxFutureIsFailed = true
false
}
}