Skip to content

Commit bbfa2b4

Browse files
Allow accepting blank session (Azure#24737)
1 parent e929867 commit bbfa2b4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpReceiver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private async Task<ReceivingAmqpLink> OpenReceiverLinkAsync(
220220
throw new ServiceBusException(true, Resources.SessionFilterMissing);
221221
}
222222

223-
if (string.IsNullOrWhiteSpace(tempSessionId))
223+
if (tempSessionId == null)
224224
{
225225
link.Session.SafeClose();
226226
throw new ServiceBusException(true, Resources.AmqpFieldSessionId);

sdk/servicebus/Azure.Messaging.ServiceBus/tests/Client/ServiceBusClientLiveTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,16 @@ public async Task AcceptNextSessionRespectsCancellation()
220220
Assert.Less(stop - start, duration.Add(duration));
221221
}
222222
}
223+
224+
[Test]
225+
public async Task CanAcceptBlankSession()
226+
{
227+
await using (var scope = await ServiceBusScope.CreateWithQueue(enablePartitioning: false, enableSession: true))
228+
{
229+
var client = CreateClient();
230+
var receiver = await client.AcceptSessionAsync(scope.QueueName, "");
231+
Assert.AreEqual("", receiver.SessionId);
232+
}
233+
}
223234
}
224235
}

0 commit comments

Comments
 (0)