:white_check_mark: SOLVED It prints the response,...
# coroutines
t
SOLVED It prints the response, but the scope is not getting finished (or the program doesn’t exit after the response).. What am i missing here? 🧵
Full code :
Copy code
@JsonClass(generateAdapter = true)
data class MockResponse(
    @Json(name = "description")
    val description: String, // Internal Server Error
    @Json(name = "statusCode")
    val statusCode: Int // 500
)

interface Api {
    @GET("200")
    suspend fun get200(): Response<MockResponse>
}

fun main() = runBlocking {
    val retrofit = Retrofit.Builder()
        .baseUrl("<https://mock.codes/>")
        .addConverterFactory(MoshiConverterFactory.create())
        .build()

    val api = retrofit.create(Api::class.java)
    println(api.get200().body())
}
s
Looking at the code, I don't think this is due to coroutines. Could it be the same issue as https://github.com/square/retrofit/issues/3144?
t
Ahaa.. that was it.
Copy code
client.dispatcher().executorService().shutdown()
    client.connectionPool().evictAll()
Fixed the issue. Thanks @Sam
s
🎉