Skip to content

Commit

Permalink
Fixed bug where DataLakeDirectoryClient(Uri,..) would throw a null ex…
Browse files Browse the repository at this point in the history
…ception if GetPaths was called (Azure#17698)
  • Loading branch information
amnguye authored Jan 5, 2021
1 parent 2ad2c21 commit dbaa81a
Show file tree
Hide file tree
Showing 5 changed files with 835 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fixed bug where the Stream returned by DataLakeFileClient.OpenRead() would return a different Length after calls to Seek().
- Added constructors taking connection string to DataLakeServiceClient, DataLakeFileSystemClient, DataLakeDirectoryClient, and DataLakeFileClient.
- Fixed bug where DataLakePathClient.SetPermissions(), DataLakeFileClient.SetPermissions(), and DataLakeDirectoryClient.SetPermissions() could not just set Owner or Group.
- Fixed bug where DataLakeDirectoryClient initialized with a Uri would throw a null exception when GetPaths() was called.

## 12.6.0-beta.1 (2020-12-07)
- Added support for service version 2020-04-08.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@ internal DataLakePathClient(
_clientDiagnostics = new ClientDiagnostics(options);
_storageSharedKeyCredential = storageSharedKeyCredential;
_blockBlobClient = BlockBlobClientInternals.Create(_blobUri, _pipeline, Version.AsBlobsVersion(), _clientDiagnostics);

uriBuilder.DirectoryOrFilePath = null;
_fileSystemClient = new DataLakeFileSystemClient(
uriBuilder.ToDfsUri(),
_pipeline,
storageSharedKeyCredential,
Version,
ClientDiagnostics);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4836,6 +4836,31 @@ public async Task GetPathsAsync()
Assert.AreEqual($"{directoryName}/foo", paths[2].Name);
}

[Test]
public async Task GetPathsAsync_UriCtor()
{
// Arrange
await using DisposingFileSystem test = await GetNewFileSystem();
string directoryName = GetNewDirectoryName();
DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(test.FileSystem.Uri)
{
DirectoryOrFilePath = directoryName
};
DataLakeDirectoryClient directory = InstrumentClient(
new DataLakeDirectoryClient(uriBuilder.ToUri(), GetStorageSharedKeyCredentials(), GetOptions()));
await SetUpDirectoryForListing(directory);

// Act
AsyncPageable<PathItem> response = directory.GetPathsAsync();
IList<PathItem> paths = await response.ToListAsync();

// Assert
Assert.AreEqual(3, paths.Count);
Assert.AreEqual($"{directoryName}/bar", paths[0].Name);
Assert.AreEqual($"{directoryName}/baz", paths[1].Name);
Assert.AreEqual($"{directoryName}/foo", paths[2].Name);
}

[Test]
public async Task GetPathsAsync_Recursive()
{
Expand Down
Loading

0 comments on commit dbaa81a

Please sign in to comment.