This PR fixes an IllegalStateException that's thrown when trying to close the engineResponse.body while a different coroutine is blocked trying to read() the body.
The fix works by checking if closing the response body fails (throwing IllegalStateException). If it fails, then we can first cancel the Call (as recommended by OkHttp devs), wait a short period of time, and then close the response body successfully.
See https://github.com/awslabs/smithy-kotlin/issues/935 for the full context.
This PR fixes an
IllegalStateException
that's thrown when trying to close theengineResponse.body
while a different coroutine is blocked trying toread()
the body.The fix works by checking if closing the response body fails (throwing
IllegalStateException
). If it fails, then we can first cancel theCall
(as recommended by OkHttp devs), wait a short period of time, and then close the response body successfully.Issue \
Closes https://github.com/awslabs/smithy-kotlin/issues/935
Description of changes
This change is required to support closing event streams before they have been fully consumed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.