Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent validating crc32 checksum on incomplete response stream #5224

Merged
merged 7 commits into from
May 17, 2024

Conversation

L-Applin
Copy link
Contributor

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 erroneous Crc32MismatchException.

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 the Crc32ChecksumValidatingInputStream). Currently, this checksum validation will then throw a Crc32MismatchException since only part of the body was read. The error returned to the user will be this Crc32MismatchException 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

@L-Applin L-Applin requested a review from a team as a code owner May 15, 2024 21:13
@L-Applin L-Applin enabled auto-merge (squash) May 17, 2024 15:08
Copy link

sonarcloud bot commented May 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
D Reliability Rating on New Code (required ≥ A)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@L-Applin L-Applin merged commit 37c5d05 into master May 17, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants