From e43b4e0b6bda3ab754011f8c8135a98cb603e04f Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Thu, 1 Aug 2024 17:29:57 -0400 Subject: [PATCH] Also call `stream.close()` if cancelled --- .../runtime/http/engine/crt/SdkStreamResponseHandler.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandler.kt b/runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandler.kt index 5bd69e6f6..d04deb6f5 100644 --- a/runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandler.kt +++ b/runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/SdkStreamResponseHandler.kt @@ -149,7 +149,11 @@ internal class SdkStreamResponseHandler( } // short circuit, stop buffering data and discard remaining incoming bytes - if (isCancelled) return bodyBytesIn.len + if (isCancelled) { + crtStream?.close() + stream.close() + return bodyBytesIn.len + } val buffer = SdkBuffer().apply { val bytes = bodyBytesIn.readAll()