Prevent validating crc32 checksum on incomplete response stream #5224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change is to enhance customer experience when dealing with
IOException
. It will prevent validating checksum when an error is encountered during reading the response body input stream and return to the user the actual error that cause a read to fail instead of the erroneousCrc32MismatchException
.Motivation and Context
When an error is encountered during reading the response body, the un-marshalling of the json response is aborted. The un-marshalling abortion logic includes a call to
InputStream.close()
which in turns will trigger validating the checksum (checksum validation is performed upon closing theCrc32ChecksumValidatingInputStream
). Currently, this checksum validation will then throw aCrc32MismatchException
since only part of the body was read. The error returned to the user will be thisCrc32MismatchException
and the underlying actual cause for the failure to read from the input stream will be ignored and difficult to troubleshoot.Modifications
Add a flag to
Crc32ChecksumValidatingInputStream
class to not validate checksum if an error is encounter during reading from the response input stream.Testing
Added unit test.
Manual test against dynamodb.
Screenshots (if appropriate)
Types of changes