I upgraded to ktor 1.0.1 and now consistently get ...
# ktor
r
I upgraded to ktor 1.0.1 and now consistently get
java.util.concurrent.CancellationException: Channel has been cancelled
from the ktor client, using CIO, with the same code that used to work with 1.0.0. Anyone else experienced this?
e
Hi, @rocketraman. It looks like side effect form the bugfix 🙂 Could you provide the example?
r
Example of client-side code?
@e5l here is some code that works with 1.0.0 but fails with 1.0.1:
Copy code
fun main(args: Array<String>) = runBlocking {
  val client = HttpClient(CIO.config { })

  suspend fun <T> download(block: suspend (ByteReadChannel) -> T): T? {
    val byteReadChannel: ByteReadChannel = client.call( "<https://www.google.com>").use {
      it.receive()
    }

    return block(byteReadChannel)
  }

  download {
    it.copyTo(System.out)
  }
  println("\nDone!!")
}
Changing the code to do the
block
inside the
call.use
works, but is this the intended behavior?
👌 2
e
If we close
call
object, it releases the response data and connection.
r
Ok, so the fact that it worked previously was accidental...
e
Yep. It was a side effect of the bug.