Skip to content

Commit

Permalink
Use internal copy of closeQuietly to avoid location mismatches in OkH…
Browse files Browse the repository at this point in the history
…TTP versions
  • Loading branch information
rbro112 committed Oct 23, 2024
1 parent bb0c904 commit 3786390
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.emergetools.reaper.utils.OkHttpUtils.closeQuietly
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
Expand All @@ -22,7 +23,6 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.internal.closeQuietly
import java.io.IOException
import kotlin.coroutines.resumeWithException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.util.Base64
import android.util.Log
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.emergetools.reaper.utils.OkHttpUtils.closeQuietly
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
Expand All @@ -21,7 +22,6 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.internal.closeQuietly
import java.io.DataInputStream
import java.io.EOFException
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.emergetools.reaper.utils

import java.io.Closeable

internal object OkHttpUtils {

// OkHttp moved this extension function in 5.x of the OkHttp library
// To avoid resolution issues, we'll implement this extension internally.
fun Closeable.closeQuietly() {
try {
close()
} catch (rethrown: RuntimeException) {
throw rethrown
} catch (ignored: Exception) {
// Ignored
}
}
}

0 comments on commit 3786390

Please sign in to comment.