Skip to content

Commit

Permalink
refactor(clearly-defined): Remove the callBlocking function
Browse files Browse the repository at this point in the history
Instead, use `runBlocking` in the only place that called the function.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
  • Loading branch information
mnonnenmacher authored and sschuberth committed Aug 20, 2024
1 parent d4d17d0 commit dbc3fc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ suspend fun <T> ClearlyDefinedService.call(block: suspend ClearlyDefinedService.
throw IOException(errorMessage, e)
}

fun <T> ClearlyDefinedService.callBlocking(block: suspend ClearlyDefinedService.() -> T): T =
runBlocking(Dispatchers.IO) { call(block) }

fun ClearlyDefinedService.getDefinitionsChunked(
coordinates: Collection<Coordinates>,
chunkSize: Int = ClearlyDefinedService.MAX_REQUEST_CHUNK_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import org.ossreviewtoolkit.clients.clearlydefined.CurationDescribed
import org.ossreviewtoolkit.clients.clearlydefined.CurationLicensed
import org.ossreviewtoolkit.clients.clearlydefined.HarvestStatus
import org.ossreviewtoolkit.clients.clearlydefined.Patch
import org.ossreviewtoolkit.clients.clearlydefined.callBlocking
import org.ossreviewtoolkit.clients.clearlydefined.getDefinitionsChunked
import org.ossreviewtoolkit.clients.clearlydefined.toCoordinates
import org.ossreviewtoolkit.model.Package
Expand All @@ -55,6 +54,7 @@ import org.ossreviewtoolkit.plugins.commands.api.OrtCommand
import org.ossreviewtoolkit.plugins.commands.api.utils.inputGroup
import org.ossreviewtoolkit.utils.common.expandTilde
import org.ossreviewtoolkit.utils.ort.OkHttpClientHelper
import org.ossreviewtoolkit.utils.ort.runBlocking

class UploadCurationsCommand : OrtCommand(
name = "upload-curations",
Expand Down Expand Up @@ -129,7 +129,7 @@ class UploadCurationsCommand : OrtCommand(
)

runCatching {
service.callBlocking { putCuration(patch) }
runBlocking { service.putCuration(patch) }
}.onSuccess {
echo("was uploaded successfully:\n${it.url}")
++uploadedCurationsCount
Expand Down

0 comments on commit dbc3fc5

Please sign in to comment.