Skip to content

Commit 8f1c728

Browse files
oshaielizarov
authored andcommitted
replace deprecated cancel with completeExceptionally
1 parent 66f0123 commit 8f1c728

File tree

1 file changed

+2
-2
lines changed
  • integration/kotlinx-coroutines-jdk8/src/future

1 file changed

+2
-2
lines changed

integration/kotlinx-coroutines-jdk8/src/future/Future.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ public fun <T> CompletionStage<T>.asDeferred(): Deferred<T> {
9595
} catch (e: Throwable) {
9696
// unwrap original cause from ExecutionException
9797
val original = (e as? ExecutionException)?.cause ?: e
98-
CompletableDeferred<T>().also { it.cancel(original) }
98+
CompletableDeferred<T>().also { it.completeExceptionally(original) }
9999
}
100100
}
101101
val result = CompletableDeferred<T>()
102102
whenComplete { value, exception ->
103103
if (exception == null) {
104104
result.complete(value)
105105
} else {
106-
result.cancel(exception)
106+
result.completeExceptionally(exception)
107107
}
108108
}
109109
if (this is Future<*>) result.cancelFutureOnCompletion(this)

0 commit comments

Comments
 (0)