From 47b9af93d6761931f4e60b6e57ca41c7b4581e7c Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Mon, 2 Oct 2023 12:24:02 -0400 Subject: [PATCH] Consistently avoid non-local returns --- .../kotlin/com/connectrpc/protocols/GRPCInterceptor.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/src/main/kotlin/com/connectrpc/protocols/GRPCInterceptor.kt b/library/src/main/kotlin/com/connectrpc/protocols/GRPCInterceptor.kt index 86b59727..ef797b04 100644 --- a/library/src/main/kotlin/com/connectrpc/protocols/GRPCInterceptor.kt +++ b/library/src/main/kotlin/com/connectrpc/protocols/GRPCInterceptor.kt @@ -142,14 +142,16 @@ internal class GRPCInterceptor( val completion = completionParser.parse(headers, emptyMap()) if (completion != null) { val exception = completion.toConnectExceptionOrNull(serializationStrategy) - return@fold StreamResult.Complete( + StreamResult.Complete( code = exception?.code ?: Code.OK, cause = exception, trailers = headers, ) + } else { + responseCompressionPool = clientConfig + .compressionPool(headers[GRPC_ENCODING]?.first()) + StreamResult.Headers(headers) } - responseCompressionPool = clientConfig.compressionPool(headers[GRPC_ENCODING]?.first()) - StreamResult.Headers(headers) }, onMessage = { result -> val (_, unpackedMessage) = Envelope.unpackWithHeaderByte(