Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repaired some of ListenableFuture.kt's cancellation corner cases.
This fixes: - Cancellation without an untrapped CancellationException propagating through a Callback; isCancelled() is the correct way to check for cancellation - Bidirectional propagation of cancellation through `asListenableFuture()` - The cause getting lost in the `asListenableFuture()` future when cancelling its `Deferred` parent with a cause This also: - Extensively documents the package and the contracts created by the promise-creating extension methods and `future()` - Uses `getUninterruptibly()` for speed - Uses `AbstractFuture` to make as certain as possible that `Future.cancel()` will return `true` at most once - Should clear up rare spooky race conditions around cancellation/interruption in hybrid Coroutines/Guava Futures codebases There are probably a few more interesting corner cases hiding in here, but this should be a good start improving the correctness of `.guava`'s adapters. This is a squash commit of kotlin/pr/1347, rebased on develop: - Incorporated first-round feedback. - Merged CancellationToCoroutine into ListenableFutureCoroutine to save an allocation. - Documented and tested for null completion of asDeferred()'s parent Future. - Renamed a cancellation test case for clarity of purpose. - Split asDeferred() documentation between KDoc/details - Implemented InternalFutures faster-fast path. Documented.
- Loading branch information