Skip to content

Commit dbaa81a

Browse files
authored
Fixed bug where DataLakeDirectoryClient(Uri,..) would throw a null exception if GetPaths was called (Azure#17698)
1 parent 2ad2c21 commit dbaa81a

File tree

5 files changed

+835
-0
lines changed

5 files changed

+835
-0
lines changed

sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fixed bug where the Stream returned by DataLakeFileClient.OpenRead() would return a different Length after calls to Seek().
55
- Added constructors taking connection string to DataLakeServiceClient, DataLakeFileSystemClient, DataLakeDirectoryClient, and DataLakeFileClient.
66
- Fixed bug where DataLakePathClient.SetPermissions(), DataLakeFileClient.SetPermissions(), and DataLakeDirectoryClient.SetPermissions() could not just set Owner or Group.
7+
- Fixed bug where DataLakeDirectoryClient initialized with a Uri would throw a null exception when GetPaths() was called.
78

89
## 12.6.0-beta.1 (2020-12-07)
910
- Added support for service version 2020-04-08.

sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ internal DataLakePathClient(
435435
_clientDiagnostics = new ClientDiagnostics(options);
436436
_storageSharedKeyCredential = storageSharedKeyCredential;
437437
_blockBlobClient = BlockBlobClientInternals.Create(_blobUri, _pipeline, Version.AsBlobsVersion(), _clientDiagnostics);
438+
439+
uriBuilder.DirectoryOrFilePath = null;
440+
_fileSystemClient = new DataLakeFileSystemClient(
441+
uriBuilder.ToDfsUri(),
442+
_pipeline,
443+
storageSharedKeyCredential,
444+
Version,
445+
ClientDiagnostics);
438446
}
439447

440448
/// <summary>

sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4836,6 +4836,31 @@ public async Task GetPathsAsync()
48364836
Assert.AreEqual($"{directoryName}/foo", paths[2].Name);
48374837
}
48384838

4839+
[Test]
4840+
public async Task GetPathsAsync_UriCtor()
4841+
{
4842+
// Arrange
4843+
await using DisposingFileSystem test = await GetNewFileSystem();
4844+
string directoryName = GetNewDirectoryName();
4845+
DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(test.FileSystem.Uri)
4846+
{
4847+
DirectoryOrFilePath = directoryName
4848+
};
4849+
DataLakeDirectoryClient directory = InstrumentClient(
4850+
new DataLakeDirectoryClient(uriBuilder.ToUri(), GetStorageSharedKeyCredentials(), GetOptions()));
4851+
await SetUpDirectoryForListing(directory);
4852+
4853+
// Act
4854+
AsyncPageable<PathItem> response = directory.GetPathsAsync();
4855+
IList<PathItem> paths = await response.ToListAsync();
4856+
4857+
// Assert
4858+
Assert.AreEqual(3, paths.Count);
4859+
Assert.AreEqual($"{directoryName}/bar", paths[0].Name);
4860+
Assert.AreEqual($"{directoryName}/baz", paths[1].Name);
4861+
Assert.AreEqual($"{directoryName}/foo", paths[2].Name);
4862+
}
4863+
48394864
[Test]
48404865
public async Task GetPathsAsync_Recursive()
48414866
{

0 commit comments

Comments
 (0)