Skip to content

Commit be8c929

Browse files
authored
Zero length share file (Azure#23165)
* nothing * Fixed a bug that caused failure to download a zero length file * Changelog * Minor cleanup * moved files to correct location
1 parent 23135a5 commit be8c929

File tree

5 files changed

+190
-4
lines changed

5 files changed

+190
-4
lines changed

sdk/storage/azure-storage-file-share/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 12.11.0-beta.1 (Unreleased)
44
- Added support to reliably download a file.
55
- Added support for the 2020-10-02 service version.
6+
- Fixed a bug that was cause an Exception when downloading a zero length file.
67

78
## 12.10.0 (2021-06-09)
89
- GA release

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileDownloadOptio
934934

935935
private Mono<StreamResponse> downloadRange(ShareFileRange range, Boolean rangeGetContentMD5,
936936
ShareRequestConditions requestConditions, Context context) {
937-
String rangeString = range == null ? null : range.toString();
937+
String rangeString = range == null ? null : range.toHeaderValue();
938938
return azureFileStorageClient.getFiles().downloadWithResponseAsync(shareName, filePath, null,
939939
rangeString, rangeGetContentMD5, requestConditions.getLeaseId(), context);
940940
}

sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,10 @@ class FileAPITests extends APISpec {
423423
headers.getContentLanguage() == null
424424
}
425425

426+
@Unroll
426427
def "Download empty file"() {
427428
setup:
428-
primaryFileClient.create(1)
429+
primaryFileClient.create(fileSize)
429430

430431
when:
431432
def outStream = new ByteArrayOutputStream()
@@ -434,8 +435,15 @@ class FileAPITests extends APISpec {
434435

435436
then:
436437
notThrown(ShareStorageException)
437-
result.length == 1
438-
!result[0]
438+
result.length == fileSize
439+
if (fileSize > 0) {
440+
assert !result[0]
441+
}
442+
443+
where:
444+
fileSize | _
445+
0 | _
446+
1 | _
439447
}
440448

441449
/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "PUT",
4+
"Uri" : "http://REDACTED.file.core.windows.net/9d333c709d333c70fba94600fd73eec9fb234ee0a6?restype=share",
5+
"Headers" : {
6+
"x-ms-version" : "2020-10-02",
7+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "531d5496-b049-4f98-83a8-efb1446c394a"
9+
},
10+
"Response" : {
11+
"content-length" : "0",
12+
"x-ms-version" : "2020-10-02",
13+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
14+
"eTag" : "0x8D94E2B56247CF4",
15+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:48 GMT",
16+
"retry-after" : "0",
17+
"StatusCode" : "201",
18+
"x-ms-request-id" : "eb6801dd-101a-0028-5a14-80bb6a000000",
19+
"x-ms-client-request-id" : "531d5496-b049-4f98-83a8-efb1446c394a",
20+
"Date" : "Fri, 23 Jul 2021 22:43:48 GMT"
21+
},
22+
"Exception" : null
23+
}, {
24+
"Method" : "PUT",
25+
"Uri" : "http://REDACTED.file.core.windows.net/9d333c709d333c70fba94600fd73eec9fb234ee0a6/9d333c709d333c70fba40108939f74771690471384",
26+
"Headers" : {
27+
"x-ms-version" : "2020-10-02",
28+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "a3cc3709-8ce2-4344-9bb4-b63bed655175"
30+
},
31+
"Response" : {
32+
"content-length" : "0",
33+
"x-ms-version" : "2020-10-02",
34+
"x-ms-file-permission-key" : "8870206874218656067*15256408171089631693",
35+
"x-ms-file-id" : "13835128424026341376",
36+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
37+
"x-ms-file-creation-time" : "2021-07-23T22:43:49.0303180Z",
38+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:49 GMT",
39+
"retry-after" : "0",
40+
"StatusCode" : "201",
41+
"x-ms-request-server-encrypted" : "true",
42+
"Date" : "Fri, 23 Jul 2021 22:43:48 GMT",
43+
"x-ms-file-attributes" : "Archive",
44+
"x-ms-file-change-time" : "2021-07-23T22:43:49.0303180Z",
45+
"x-ms-file-parent-id" : "0",
46+
"eTag" : "0x8D94E2B566EE0CC",
47+
"x-ms-request-id" : "053a3180-101a-0007-0d14-80b6a1000000",
48+
"x-ms-client-request-id" : "a3cc3709-8ce2-4344-9bb4-b63bed655175",
49+
"x-ms-file-last-write-time" : "2021-07-23T22:43:49.0303180Z"
50+
},
51+
"Exception" : null
52+
}, {
53+
"Method" : "GET",
54+
"Uri" : "http://REDACTED.file.core.windows.net/9d333c709d333c70fba94600fd73eec9fb234ee0a6/9d333c709d333c70fba40108939f74771690471384",
55+
"Headers" : {
56+
"x-ms-version" : "2020-10-02",
57+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
58+
"x-ms-client-request-id" : "01739042-a73a-4650-a9ed-80b3572db494"
59+
},
60+
"Response" : {
61+
"content-length" : "0",
62+
"x-ms-version" : "2020-10-02",
63+
"x-ms-lease-status" : "unlocked",
64+
"x-ms-file-permission-key" : "8870206874218656067*15256408171089631693",
65+
"x-ms-file-id" : "13835128424026341376",
66+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
67+
"x-ms-file-creation-time" : "2021-07-23T22:43:49.0303180Z",
68+
"x-ms-lease-state" : "available",
69+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:49 GMT",
70+
"retry-after" : "0",
71+
"StatusCode" : "200",
72+
"Date" : "Fri, 23 Jul 2021 22:43:49 GMT",
73+
"Accept-Ranges" : "bytes",
74+
"x-ms-server-encrypted" : "true",
75+
"x-ms-type" : "File",
76+
"x-ms-file-attributes" : "Archive",
77+
"x-ms-file-change-time" : "2021-07-23T22:43:49.0303180Z",
78+
"x-ms-file-parent-id" : "0",
79+
"eTag" : "0x8D94E2B566EE0CC",
80+
"x-ms-request-id" : "eb68020b-101a-0028-6e14-80bb6a000000",
81+
"x-ms-client-request-id" : "01739042-a73a-4650-a9ed-80b3572db494",
82+
"x-ms-file-last-write-time" : "2021-07-23T22:43:49.0303180Z",
83+
"Content-Type" : "application/octet-stream"
84+
},
85+
"Exception" : null
86+
} ],
87+
"variables" : [ "9d333c709d333c70fba94600fd73eec9fb234ee0a6", "9d333c709d333c70fba40108939f74771690471384" ]
88+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "PUT",
4+
"Uri" : "http://REDACTED.file.core.windows.net/84280d3184280d316c5987171a54c1eb72a24bf5a4?restype=share",
5+
"Headers" : {
6+
"x-ms-version" : "2020-10-02",
7+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "5ce6a806-65da-4418-950c-ec29848ef929"
9+
},
10+
"Response" : {
11+
"content-length" : "0",
12+
"x-ms-version" : "2020-10-02",
13+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
14+
"eTag" : "0x8D94E2B56245AF9",
15+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:48 GMT",
16+
"retry-after" : "0",
17+
"StatusCode" : "201",
18+
"x-ms-request-id" : "053a3157-101a-0007-6a14-80b6a1000000",
19+
"x-ms-client-request-id" : "5ce6a806-65da-4418-950c-ec29848ef929",
20+
"Date" : "Fri, 23 Jul 2021 22:43:47 GMT"
21+
},
22+
"Exception" : null
23+
}, {
24+
"Method" : "PUT",
25+
"Uri" : "http://REDACTED.file.core.windows.net/84280d3184280d316c5987171a54c1eb72a24bf5a4/84280d3184280d316c56691523bafecac27c4bb0bc",
26+
"Headers" : {
27+
"x-ms-version" : "2020-10-02",
28+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "ef9391e2-d996-4790-a675-fff7718f97d1"
30+
},
31+
"Response" : {
32+
"content-length" : "0",
33+
"x-ms-version" : "2020-10-02",
34+
"x-ms-file-permission-key" : "8870206874218656067*15256408171089631693",
35+
"x-ms-file-id" : "13835128424026341376",
36+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
37+
"x-ms-file-creation-time" : "2021-07-23T22:43:49.0313178Z",
38+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:49 GMT",
39+
"retry-after" : "0",
40+
"StatusCode" : "201",
41+
"x-ms-request-server-encrypted" : "true",
42+
"Date" : "Fri, 23 Jul 2021 22:43:49 GMT",
43+
"x-ms-file-attributes" : "Archive",
44+
"x-ms-file-change-time" : "2021-07-23T22:43:49.0313178Z",
45+
"x-ms-file-parent-id" : "0",
46+
"eTag" : "0x8D94E2B566F07DA",
47+
"x-ms-request-id" : "eb680203-101a-0028-6b14-80bb6a000000",
48+
"x-ms-client-request-id" : "ef9391e2-d996-4790-a675-fff7718f97d1",
49+
"x-ms-file-last-write-time" : "2021-07-23T22:43:49.0313178Z"
50+
},
51+
"Exception" : null
52+
}, {
53+
"Method" : "GET",
54+
"Uri" : "http://REDACTED.file.core.windows.net/84280d3184280d316c5987171a54c1eb72a24bf5a4/84280d3184280d316c56691523bafecac27c4bb0bc",
55+
"Headers" : {
56+
"x-ms-version" : "2020-10-02",
57+
"User-Agent" : "azsdk-java-azure-storage-file-share/12.11.0-beta.1 (11.0.7; Windows 10; 10.0)",
58+
"x-ms-client-request-id" : "7238eebc-381d-4004-9452-0cd49eb5efd0"
59+
},
60+
"Response" : {
61+
"content-length" : "1",
62+
"x-ms-version" : "2020-10-02",
63+
"x-ms-lease-status" : "unlocked",
64+
"x-ms-file-permission-key" : "8870206874218656067*15256408171089631693",
65+
"x-ms-file-id" : "13835128424026341376",
66+
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
67+
"x-ms-file-creation-time" : "2021-07-23T22:43:49.0313178Z",
68+
"x-ms-lease-state" : "available",
69+
"Last-Modified" : "Fri, 23 Jul 2021 22:43:49 GMT",
70+
"retry-after" : "0",
71+
"StatusCode" : "200",
72+
"Date" : "Fri, 23 Jul 2021 22:43:48 GMT",
73+
"Accept-Ranges" : "bytes",
74+
"x-ms-server-encrypted" : "true",
75+
"x-ms-type" : "File",
76+
"x-ms-file-attributes" : "Archive",
77+
"x-ms-file-change-time" : "2021-07-23T22:43:49.0313178Z",
78+
"x-ms-file-parent-id" : "0",
79+
"eTag" : "0x8D94E2B566F07DA",
80+
"x-ms-request-id" : "053a3189-101a-0007-1214-80b6a1000000",
81+
"Body" : "AA==",
82+
"x-ms-client-request-id" : "7238eebc-381d-4004-9452-0cd49eb5efd0",
83+
"x-ms-file-last-write-time" : "2021-07-23T22:43:49.0313178Z",
84+
"Content-Type" : "application/octet-stream"
85+
},
86+
"Exception" : null
87+
} ],
88+
"variables" : [ "84280d3184280d316c5987171a54c1eb72a24bf5a4", "84280d3184280d316c56691523bafecac27c4bb0bc" ]
89+
}

0 commit comments

Comments
 (0)