From 0afe3011bcac9c84a36ec2f5c586f77f8f5a129a Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 27 Apr 2021 17:50:55 -0400 Subject: [PATCH] Better handling of coroutine cancellations for http calls Based on https://github.com/tachiyomiorg/tachiyomi-1.x/commit/b94b7eeb6d28a4c3f39488388589fa913c43fe5e --- .../java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt index f50c71a93..099289f54 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt @@ -9,6 +9,7 @@ import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response +import okhttp3.internal.closeQuietly import rx.Observable import rx.Producer import rx.Subscription @@ -70,7 +71,9 @@ suspend fun Call.await(): Response { return } - continuation.resume(response) + continuation.resume(response) { + response.body?.closeQuietly() + } } override fun onFailure(call: Call, e: IOException) {