Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 93ab7b0

Browse files
SeanFeldmannemakam
authored andcommitted
Fix #579 - correct error message (#580)
Fixes #579 For an empty list do not throw argument null exception
1 parent 1d5df37 commit 93ab7b0

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

src/Microsoft.Azure.ServiceBus/Core/MessageReceiver.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public MessageReceiver(
9797
{
9898
throw Fx.Exception.ArgumentNullOrWhiteSpace(connectionString);
9999
}
100-
100+
101101
this.OwnsConnection = true;
102102
}
103103

@@ -158,7 +158,7 @@ internal MessageReceiver(
158158
string sessionId = null,
159159
bool isSessionReceiver = false)
160160
: base(nameof(MessageReceiver), entityPath, retryPolicy ?? RetryPolicy.Default)
161-
{
161+
{
162162
MessagingEventSource.Log.MessageReceiverCreateStart(serviceBusConnection?.Endpoint.Authority, entityPath, receiveMode.ToString());
163163

164164
if (string.IsNullOrWhiteSpace(entityPath))
@@ -512,7 +512,7 @@ public async Task CompleteAsync(IEnumerable<string> lockTokens)
512512
var lockTokenList = lockTokens.ToList();
513513
if (lockTokenList.Count == 0)
514514
{
515-
throw Fx.Exception.ArgumentNull(nameof(lockTokens));
515+
throw Fx.Exception.Argument(nameof(lockTokens), Resources.ListOfLockTokensCannotBeEmty);
516516
}
517517

518518
MessagingEventSource.Log.MessageCompleteStart(this.ClientId, lockTokenList.Count, lockTokenList);
@@ -1523,13 +1523,13 @@ async Task<ReceivingAmqpLink> CreateLinkAsync(TimeSpan timeout)
15231523
var endpointUri = new Uri(this.ServiceBusConnection.Endpoint, this.Path);
15241524
var claims = new[] { ClaimConstants.Listen };
15251525
var amqpSendReceiveLinkCreator = new AmqpSendReceiveLinkCreator(
1526-
this.Path,
1527-
this.ServiceBusConnection,
1528-
endpointUri,
1529-
new string[] { endpointUri.AbsoluteUri },
1530-
claims,
1531-
this.CbsTokenProvider,
1532-
amqpLinkSettings,
1526+
this.Path,
1527+
this.ServiceBusConnection,
1528+
endpointUri,
1529+
new string[] { endpointUri.AbsoluteUri },
1530+
claims,
1531+
this.CbsTokenProvider,
1532+
amqpLinkSettings,
15331533
this.ClientId);
15341534

15351535
Tuple<AmqpObject, DateTime> linkDetails = await amqpSendReceiveLinkCreator.CreateAndOpenAmqpLinkAsync().ConfigureAwait(false);
@@ -1561,13 +1561,13 @@ async Task<RequestResponseAmqpLink> CreateRequestResponseLinkAsync(TimeSpan time
15611561
var endpointUri = new Uri(this.ServiceBusConnection.Endpoint, entityPath);
15621562
string[] claims = { ClaimConstants.Manage, ClaimConstants.Listen };
15631563
var amqpRequestResponseLinkCreator = new AmqpRequestResponseLinkCreator(
1564-
entityPath,
1565-
this.ServiceBusConnection,
1564+
entityPath,
1565+
this.ServiceBusConnection,
15661566
endpointUri,
15671567
new string[] { endpointUri.AbsoluteUri },
1568-
claims,
1569-
this.CbsTokenProvider,
1570-
amqpLinkSettings,
1568+
claims,
1569+
this.CbsTokenProvider,
1570+
amqpLinkSettings,
15711571
this.ClientId);
15721572

15731573
var linkDetails = await amqpRequestResponseLinkCreator.CreateAndOpenAmqpLinkAsync().ConfigureAwait(false);

src/Microsoft.Azure.ServiceBus/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Azure.ServiceBus/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@
159159
<data name="TokenMissingExpiresOn" xml:space="preserve">
160160
<value>The provided token does not specify the 'ExpiresOn' value.</value>
161161
</data>
162+
<data name="ListOfLockTokensCannotBeEmty" xml:space="preserve">
163+
<value>List of lock tokens cannot be empty</value>
164+
</data>
162165
<data name="NotSupportedPropertyType" xml:space="preserve">
163166
<value>'{0}' is not a supported type.</value>
164167
</data>

0 commit comments

Comments
 (0)