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

ShareFileClient.DownloadToFile Removing Retry.max(3) #43093

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ibrahimrabab
Copy link
Contributor

Description

Removing extra outer retries in downloadToFile as this was causing a mismatch in bytes downloaded when inner retries from downloadWithResponse's FluxUtil.createRetriableDownloadFlux were exhausted.

@github-actions github-actions bot added the Storage Storage Service (Queues, Blobs, Files) label Nov 26, 2024
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@Override
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
return next.process().flatMap(response -> {
HttpHeader rangeHttpHeader = response.getRequest().getHeaders().get(RANGE_HEADER);
Copy link
Member

Choose a reason for hiding this comment

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

Are we always guaranteed for consumers of this to use x-ms-range as the range header? If not, in the future when needed this could be modified to include a header in the constructor to determine which header to look for.

Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good! I just had some minor suggestions on refactoring the tests that got added.

Copy link
Member

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. Just had a couple more comments and we should be set here.

@@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- `ShareFileClient.downloadToFile()` now retries for a maximum of 5 times when the download fails due to a network error.
Copy link
Member

Choose a reason for hiding this comment

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

Let's also include what the previous maximum (15) and note both that the number of reties was unintentional and that the additional retires past the intended maximum of 5 could lead to writing in incorrect positions in the file.

// Assert that the range headers that were retried match what was returned from MockPartialResponsePolicy
List<String> expectedRanges = expectedHeaderRanges();
List<String> actualRanges = policy.getRangeHeaders();
assertEquals(expectedRanges.size(), actualRanges.size());
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to remove the size assertion here and defer to the direct equals assertion of the two lists for these test cases so just:

assertEquals(expectedRanges, actualRanges);

List<String> expectedRanges = expectedHeaderRanges();
List<String> actualRanges = policy.getRangeHeaders();
assertEquals(expectedRanges.size(), actualRanges.size());

Copy link
Member

Choose a reason for hiding this comment

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

I think we forgot to add the assertEquals here for the two lists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants