https://kotlinlang.org logo
#ktor
Title
# ktor
r

russhwolf

05/28/2019, 9:03 PM
It's more idiomatic to call
client.use { ... }
instead of
client.also { ... }
. That will call
close()
automatically.
i

irus

05/28/2019, 9:11 PM
It's not the point, why client closes automatically in 1.1.1, and required to be closed in 1.2.1. Looks like
close
method not calling on
Engine
in both version, code which create AsyncHttpClient is the same. I have no idea what to check also
@e5l how it possible, that JVM terminates without explicit client.close() in 1.1.1?
e

e5l

05/29/2019, 7:41 AM
Client holds
runBlocking
if some connection is still active. Probably the validate method doesn’t close the response.
i

irus

05/29/2019, 2:28 PM
Copy code
fun main() {
    val client = AppStoreClient("...", "...")

    runBlocking {
        println(client.validate("..."))
    }

    println("Done")
}
In this case
Done
will be printed, but JVM: 1. ktor-client:1.1.1 - stopped 2. ktor-client 1.2.1 - keep running