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

Simplifying and unifying every Base class constructors to go via comm… #4529

Merged
merged 2 commits into from
Jul 8, 2018

Conversation

shahabhijeet
Copy link
Member

  1. Simplifying and unifying every Base class constructors to go via common code path.
  2. Simplifying logic to avoid adding duplicate userAgent strings.
  3. Making sure we use ConfigureAwait(false) where it was missing.
  4. Adding tests

…on code path.

Simplifying logic to avoid adding duplicate userAgent strings.
Making sure we use ConfigureAwait(false) where it was missing.
Adding tests.
Copy link

@EricDahlvang EricDahlvang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the issues raised here:
#4086
and
#3712

foreach(ProductInfoHeaderValue piHv in defaultUserAgentInfoList)
{
if(!HttpClient.DefaultRequestHeaders.UserAgent.Any<ProductInfoHeaderValue>((hv) => hv.Product.Name.Equals(piHv.Product.Name, StringComparison.OrdinalIgnoreCase)));
if(!HttpClient.DefaultRequestHeaders.UserAgent.Any<ProductInfoHeaderValue>((hv) => hv.Product.Name.Equals(piHv.Product.Name, StringComparison.OrdinalIgnoreCase)))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not account for UserAgent strings that are comments only. They will NOT have a .Product property... this will throw a null reference exception. If this constructor is used https://technet.microsoft.com/en-us/library/hh138008(v=vs.110) then ProductInfoHeaderValue will have only a comment.

private void AddUserAgentEntry(ProductInfoHeaderValue pInfoHeaderValue)
{
if (!HttpClient.DefaultRequestHeaders.UserAgent.Contains<ProductInfoHeaderValue>(pInfoHeaderValue,
new ObjectComparer<ProductInfoHeaderValue>((left, right) => left.Product.Name.Equals(right.Product.Name, StringComparison.OrdinalIgnoreCase))))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not account for UserAgent strings that are comments only. They will NOT have a .Product property... this will throw a null reference exception.

{
}

: this(serviceHttpClient: null, rootHandler: CreateRootHandler(), disposeHttpClient: true, delHandlers: null) { }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateRootHandler is called by this constructor. This code creates a HttpClientHandler or WebRequestHandler that is then never disposed. Please see #3712

@shahabhijeet shahabhijeet merged commit 24ae395 into Azure:psSdkJson6 Jul 8, 2018
@shahabhijeet shahabhijeet deleted the fixCR branch September 4, 2018 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants