Marcelo Hernandez
03/23/2020, 10:57 PMCoroutineWorker#startWork
, it seems it doesn't take CancellationException
into account. It catches Throwable
and sets the exception on the future.
@Suppress("DEPRECATION")
final override fun startWork(): ListenableFuture<Result> {
val coroutineScope = CoroutineScope(coroutineContext + job)
coroutineScope.launch {
try {
val result = doWork()
future.set(result)
} catch (t: Throwable) {
future.setException(t)
}
}
return future
}
Should implementations of doWork()
have to handle CancellationException
themselves?