Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

XmlException causing performance hit when checking the existance of a non-existant directory #835

Open
crackalak opened this issue Dec 20, 2018 · 0 comments
Assignees

Comments

@crackalak
Copy link

crackalak commented Dec 20, 2018

Which service(blob, file, queue, table) does this issue concern?

File

Which version of the SDK was used?

9.4.2

Which platform are you using? (ex: .NET Core 2.1)

.NET Core 2.1

What problem was encountered?

XmlException is thrown, and silently handled, when checking if a non-existant directory exists with Exists/ExistsAsync(), this affects performance (~+200ms).

How can we reproduce the problem in the simplest way?

Gist

Have you found a mitigation/solution?

HttpClient returns a Stream of value EmptyReadStream when it receives an empty response body, this Stream has CanSeek = false which gets past the check of an empty stream here:

if (inputStream.CanSeek && inputStream.Length < 1)

Changing the line to:
if (!inputStream.CanSeek || inputStream.Length < 1)

Means that the XmlException isn't raised when trying to read from the empty stream, and performance is restored to what it should be.

While this fixes the issue, I'm not sure if this would affect anything else (it doesn't from what I can see) or if it is how you would want to go about solving it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants