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

[Service Bus] ConnectionString parsing cleanup #10664

Merged
merged 6 commits into from
Mar 19, 2020

Conversation

ShivangiReja
Copy link
Member

@ShivangiReja ShivangiReja commented Mar 17, 2020

#9884

  • This PR is removes connectionStringBuilder class.
  • Add Validation that entityName matches conn string entity if present in both.
  • Add unit tests.

@ShivangiReja
Copy link
Member Author

Closing this PR for now, since it needs more discussion.

@@ -115,7 +115,8 @@ public static ConnectionStringProperties Parse(string connectionString)
{
parsedValues.EndpointToken = new UriBuilder(value)
{
Scheme = ServiceBusEndpointScheme
Scheme = ServiceBusEndpointScheme,
Port = -1
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, how is this used?

Copy link
Member Author

@ShivangiReja ShivangiReja Mar 19, 2020

Choose a reason for hiding this comment

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

If I parse the below connection string without setting Port = -1

ConnectionStringParser.Parse("Endpoint=ns1.servicebus.windows.net/;SharedAccessKeyName=FakeKeyName;SharedAccessKey=FakeKey;")

It returns Endpoint - "sb://ns1.servicebus.windows.net:80/"

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, do we know why this wasn't needed in the EH version?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we parse this connection string without setting Port = -1 "Endpoint=sb://ns1.servicebus.windows.net/;SharedAccessKeyName=DummyKeyName;SharedAccessKey=DummyKey"

It returns the Endpoint as expected. Meaning if we pass the connection string endpoint starting with sb:// or pb:// or anything; It doesn't append the port and returns the Endpoint as expected.

I don't know about EH. I need to ask @jsquire.

new ServiceBusProcessor(
CancellationToken cancellationToken = default)
{
if (isConnectionPropertiesValidationNeeded)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this bool? I think we should be able to detect if we need to the validation based on whether Connection.ConnectionStringProperties is null.

Copy link
Member Author

Choose a reason for hiding this comment

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

ConnectionStringProperties is a struct. It can never be null.

Copy link
Member

Choose a reason for hiding this comment

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

Well we can check the EntityName property on it. If that is null, then no validation is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we don't even need the ConnectionStringProperties property in ServiceBusConnection class. We can directly check if Connection.EntityPath is not null, then do the validation.

@@ -250,12 +234,9 @@ public ServiceBusReceiver GetReceiver(string queueName)
string topicName,
string subscriptionName)
{
if (isConnectionPropertiesValidationNeeded)
if (!string.IsNullOrEmpty(Connection.EntityPath))
Copy link
Member

Choose a reason for hiding this comment

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

super nit: move this check into ValidateEntityName.

@ShivangiReja ShivangiReja merged commit 9184b94 into Azure:master Mar 19, 2020
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