aws-sdk-kotlin
aws-sdk-kotlin copied to clipboard
IllegalStateException thrown while reading from Dynamo
Describe the bug
We use 0.16.5-beta SDK version for writing/reading from Dynamo.
While creating a new entry, we ran into the below error
java.lang.IllegalStateException: failed to read all HttpBody bytes from stream: isClosedForRead: false/true; isClosedForWrite: true/true; availableForRead: 0/0: {}at aws.smithy.kotlin.runtime.http.HttpBodyKt.readAll(HttpBody.kt:135)at aws.smithy.kotlin.runtime.http.HttpBodyKt$readAll$1.invokeSuspend(HttpBody.kt)at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Expected behavior
A dynamo specific error should be thrown instead of IllegalStateException
Current behavior
IllegalStateException was thrown.
Steps to Reproduce
This was seen only once and there is no consistent repro steps here. More specifically, we used kotlin SDK to write an entry under 4 kb to dynamo
Possible Solution
No response
Context
No response
AWS Kotlin SDK version used
0.16.5-beta
Platform (JVM/JS/Native)
JVM
Operating System and version
All
Hi @mjindalmotiv8, thanks for the bug report. Can you share any of the the code that caused this error? Was this a putItem call?
Hi @ianbotsf - Nothing super fancy - it looks like below
val putItemResponse = try {
awsClient.putItem(putItemRequest)
} catch (e: Exception) {
LOGGER.error { msg("Error while attempting to put ddb item").any("put_item_request", putItemRequest) }
throw e
}
Well then I'd guess that this was a transient network failure that got thrown as an IllegalStateException which is obviously not ideal. We should throw a clearer exception type and automatically retry it using our standard retry logic.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.