From f7429d969ca3e9bb616a7d79cc7a13b810117acb Mon Sep 17 00:00:00 2001 From: Mariia Skripchenko <61115099+marychatte@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:06:18 +0100 Subject: [PATCH] Fix api --- .../common/src/io/ktor/server/sse/Routing.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ktor-server/ktor-server-plugins/ktor-server-sse/common/src/io/ktor/server/sse/Routing.kt b/ktor-server/ktor-server-plugins/ktor-server-sse/common/src/io/ktor/server/sse/Routing.kt index b2b344bfc6..6b315737b8 100644 --- a/ktor-server/ktor-server-plugins/ktor-server-sse/common/src/io/ktor/server/sse/Routing.kt +++ b/ktor-server/ktor-server-plugins/ktor-server-sse/common/src/io/ktor/server/sse/Routing.kt @@ -146,15 +146,14 @@ private fun Route.processSSEWithoutSerialization( ) = processSSE(serialize, handler) private fun Route.processSSEWithSerialization( - serialize: ((TypeInfo, Any) -> String)?, + serialize: ((TypeInfo, Any) -> String), handler: suspend ServerSSESessionWithSerialization.() -> Unit ) { val sessionHandler: suspend ServerSSESession.() -> Unit = { - if (this is ServerSSESessionWithSerialization) { - handler() - } else { - throw IllegalStateException("ServerSSESessionWithSerialization is required.") + check(this is ServerSSESessionWithSerialization) { + "Impossible state. Please report this bug: https://youtrack.jetbrains.com/newIssue?project=KTOR" } + handler() } processSSE(serialize, sessionHandler) }