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

Fixed bug where rename would not work on URL encoded paths. #8887

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/storage/azure-storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 12.0.0-beta.13 (Unreleased)

- Fixed bug that caused rename to fail on paths that are url encoded.
- Mapped StorageErrorException and BlobStorageException to DataLakeStorageException on DataLakeServiceClient.listFileSystems

## 12.0.0-beta.12 (2020-02-12)
- Added ability to rename files and directories across file systems.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.storage.blob.models.BlobProperties;
import com.azure.storage.blob.specialized.BlockBlobClient;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.file.datalake.implementation.models.LeaseAccessConditions;
Expand Down Expand Up @@ -502,7 +503,7 @@ Mono<Response<DataLakePathClient>> renameWithResponse(String destinationFileSyst
DataLakePathClient dataLakePathClient = getPathClient(destinationFileSystem, destinationPath);

String renameSource = "/" + dataLakePathAsyncClient.getFileSystemName() + "/"
+ dataLakePathAsyncClient.getObjectPath();
+ Utility.urlEncode(dataLakePathAsyncClient.getObjectPath());

return dataLakePathClient.dataLakePathAsyncClient.dataLakeStorage.paths().createWithRestResponseAsync(
null /* pathResourceType */, null /* continuation */, PathRenameMode.LEGACY, renameSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,19 @@ class FileAPITest extends APISpec {
thrown(DataLakeStorageException)
}

def "Rename url encoded path"() {
setup:
// Add some random url encoded characters to the end
fc = fsc.getFileClient(generatePathName() + "%20%25")
fc.create()

when:
def response = fc.renameWithResponse(null, generatePathName(), null, null, null, null)

then:
response.getStatusCode() == 201
}

@Unroll
def "Rename source AC"() {
setup:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://gaprahnsstg.blob.core.windows.net/jtfsrenameurlencodedpath081458b109d79a5d7447d9?restype=container",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-blob/12.5.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "2c0ec3f8-a273-47de-9249-82477a4449d6"
},
"Response" : {
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D7C4713EFE4B6B",
"Last-Modified" : "Mon, 09 Mar 2020 21:31:36 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "6336c4f2-901e-003b-555a-f6d79f000000",
"Date" : "Mon, 09 Mar 2020 21:31:36 GMT",
"x-ms-client-request-id" : "2c0ec3f8-a273-47de-9249-82477a4449d6"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://gaprahnsstg.dfs.core.windows.net/jtfsrenameurlencodedpath081458b109d79a5d7447d9/javapathrenameurlencodedpath116979ba71d082723649?resource=file",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.0.0-beta.13 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "04ebfe64-b970-4407-a997-18ab7fdce076"
},
"Response" : {
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D7C4713FC9352F",
"Last-Modified" : "Mon, 09 Mar 2020 21:31:37 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "c5c6330d-901f-0049-125a-f6d0d0000000",
"Date" : "Mon, 09 Mar 2020 21:31:37 GMT",
"x-ms-client-request-id" : "04ebfe64-b970-4407-a997-18ab7fdce076"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://gaprahnsstg.dfs.core.windows.net/jtfsrenameurlencodedpath081458b109d79a5d7447d9/javapathrenameurlencodedpath2315078ab40f33890c45%20%25?resource=file",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.0.0-beta.13 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "da688866-cf46-4d5a-b1ae-e295f8d4ce66"
},
"Response" : {
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D7C4714058B863",
"Last-Modified" : "Mon, 09 Mar 2020 21:31:38 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "f804826d-001f-0039-485a-f66927000000",
"Date" : "Mon, 09 Mar 2020 21:31:38 GMT",
"x-ms-client-request-id" : "da688866-cf46-4d5a-b1ae-e295f8d4ce66"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://gaprahnsstg.dfs.core.windows.net/jtfsrenameurlencodedpath081458b109d79a5d7447d9/javapathrenameurlencodedpath3789155f98821f69144c?mode=legacy",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.0.0-beta.13 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "642a4c13-c2e2-49b2-8a7b-a0ca5eee72ac"
},
"Response" : {
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "a1ce1623-d01f-0048-5e5a-f68f0c000000",
"Date" : "Mon, 09 Mar 2020 21:31:38 GMT",
"x-ms-client-request-id" : "642a4c13-c2e2-49b2-8a7b-a0ca5eee72ac"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://gaprahnsstg.blob.core.windows.net?prefix=jtfsrenameurlencodedpath&comp=list",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-blob/12.5.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "1ef11350-7005-4bef-872d-f7c09501db6b"
},
"Response" : {
"Transfer-Encoding" : "chunked",
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "969ec9fe-701e-0041-595a-f6cadf000000",
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://gaprahnsstg.blob.core.windows.net/\"><Prefix>jtfsrenameurlencodedpath</Prefix><Containers><Container><Name>jtfsrenameurlencodedpath081458b109d79a5d7447d9</Name><Properties><Last-Modified>Mon, 09 Mar 2020 21:31:36 GMT</Last-Modified><Etag>\"0x8D7C4713EFE4B6B\"</Etag><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><DefaultEncryptionScope>$account-encryption-key</DefaultEncryptionScope><DenyEncryptionScopeOverride>false</DenyEncryptionScopeOverride><HasImmutabilityPolicy>false</HasImmutabilityPolicy><HasLegalHold>false</HasLegalHold></Properties></Container></Containers><NextMarker /></EnumerationResults>",
"Date" : "Mon, 09 Mar 2020 21:31:38 GMT",
"x-ms-client-request-id" : "1ef11350-7005-4bef-872d-f7c09501db6b",
"Content-Type" : "application/xml"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://gaprahnsstg.blob.core.windows.net/jtfsrenameurlencodedpath081458b109d79a5d7447d9?restype=container",
"Headers" : {
"x-ms-version" : "2019-07-07",
"User-Agent" : "azsdk-java-azure-storage-blob/12.5.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "4b1562e6-60d8-42bd-b007-19d348310a5e"
},
"Response" : {
"x-ms-version" : "2019-07-07",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "202",
"x-ms-request-id" : "e8854ff3-201e-002e-465a-f6c02c000000",
"Date" : "Mon, 09 Mar 2020 21:31:40 GMT",
"x-ms-client-request-id" : "4b1562e6-60d8-42bd-b007-19d348310a5e"
},
"Exception" : null
} ],
"variables" : [ "jtfsrenameurlencodedpath081458b109d79a5d7447d9", "javapathrenameurlencodedpath116979ba71d082723649", "javapathrenameurlencodedpath2315078ab40f33890c45", "javapathrenameurlencodedpath3789155f98821f69144c" ]
}