package org.jetbrains.ktor.netty

import io.netty.channel.*
import kotlin.coroutines.experimental.*

suspend fun ChannelFuture.suspendAwait() {
    if (isDone) return

    suspendCoroutine<Unit> { continuation ->
        addListener { f ->
            try {
                f.get()
                continuation.resume(Unit)
            } catch (t: Throwable) {
                continuation.resumeWithException(t)
            }
        }
    }
}
package org.jetbrains.ktor.netty

import io.netty.channel.*
import kotlin.coroutines.experimental.*

suspend fun ChannelFuture.suspendAwait() {
    if (isDone) return

    suspendCoroutine<Unit> { continuation ->
        addListener { f ->
            try {
                f.get()
            } catch (t: Throwable) {
                continuation.resumeWithException(t)
                return@addListener
            }
            continuation.resume(Unit)
        }
    }
}
Fix exception handling in awaiting for a channel future
Fix exception handling in awaiting for a channel future

ktorio/ktor,ktorio/ktor,ktorio/ktor,ktorio/ktor