Fix crash caused by double resume
This commit is contained in:
@@ -42,6 +42,7 @@ import java.net.NetworkInterface
|
|||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.coroutines.resume
|
||||||
import kotlin.coroutines.resumeWithException
|
import kotlin.coroutines.resumeWithException
|
||||||
|
|
||||||
tailrec fun Throwable.getRootCause(): Throwable {
|
tailrec fun Throwable.getRootCause(): Throwable {
|
||||||
@@ -274,7 +275,7 @@ suspend fun <T> connectCancellable(url: String, block: suspend (HttpURLConnectio
|
|||||||
return suspendCancellableCoroutine { cont ->
|
return suspendCancellableCoroutine { cont ->
|
||||||
val job = GlobalScope.launch(Dispatchers.IO) {
|
val job = GlobalScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
cont.resume(block(conn)) { cont.resumeWithException(it) }
|
cont.resume(block(conn))
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
cont.resumeWithException(e)
|
cont.resumeWithException(e)
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user