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

fix: update request method of HttpStorageRpc to properly configure offset on requests #1434

Merged
merged 2 commits into from
Jun 8, 2022

Conversation

BenWhitehead
Copy link
Collaborator

@BenWhitehead BenWhitehead commented Jun 6, 2022

When invoking downloadTo(..., OutputStream) if a retry was attempted the proper byte
offset was not being sent in the retried request. Update logic of HttpStorageRpc.read
to manually set the range header rather than trying to rely on MediaDownloader to do
it along with not automatically decompressing the byte stream.

Update ITRetryConformanceTest to run Scenario 8 test cases, which cover resuming a
download which could have caught this error sooner.

Update StorageException.translate(IOException) to classify IOException: Premature EOF
as the existing retryable reason connectionClosedPrematurely. Add case to
DefaultRetryHandlingBehaviorTest to ensure conformance to this categorization.

Break downloadTo integration test out into their own class, and separate
the multiple scenarios being tested in the same method.

Related to #1425

@BenWhitehead BenWhitehead requested a review from a team as a code owner June 6, 2022 21:37
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/java-storage API. labels Jun 6, 2022
mediaHttpDownloader.setBytesDownloaded(position);
mediaHttpDownloader.setDirectDownloadEnabled(true);
req.executeMediaAndDownloadTo(outputStream);
return mediaHttpDownloader.getNumBytesDownloaded();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a refactor or is there magical Apiary functionality hidden in this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be magical apiary behavior behind this. The previous code wouldn't set the Range header ever, but the new code does.

I don't fully understand what's the subtle difference between req.executeMedia().download(os) and req.executeMediaAndDownloadTo(os) but the latter results in the Range header being set if position > 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have since moved away from the previous executeAndDownload method change. This was not properly respecting returnRawInputStream which would break gzip automatic transcoding if you wanted to actually download the zipped bytes. Instead, we are now setting the range header ourselves.

…fset on requests

When invoking downloadTo(..., OutputStream) if a retry was attempted the proper byte
offset was not being sent in the retried request. Update logic of HttpStorageRpc.read
to manually set the range header rather than trying to rely on MediaDownloader to do
it along with not automatically decompressing the byte stream.

Update ITRetryConformanceTest to run Scenario 8 test cases, which cover resuming a
download which could have caught this error sooner.

Update StorageException.translate(IOException) to classify `IOException: Premature EOF`
as the existing retryable reason `connectionClosedPrematurely`. Add case to
DefaultRetryHandlingBehaviorTest to ensure conformance to this categorization.

Break downloadTo integration test out into their own class, and separate
the multiple scenarios being tested in the same method.

Related to #1425
@BenWhitehead BenWhitehead force-pushed the add-s8-conformance-tests branch from 4c21e20 to 0f2ef8a Compare June 8, 2022 19:04
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jun 8, 2022
@BenWhitehead BenWhitehead merged commit 72dc0df into main Jun 8, 2022
@BenWhitehead BenWhitehead deleted the add-s8-conformance-tests branch June 8, 2022 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants