-
Notifications
You must be signed in to change notification settings - Fork 120
NullReferenceException when accessing message.Size property #648
Comments
Technically, the body can be either @dolly22 if your code needs to handle null body messages, shouldn't it then even bother with the |
@dolly22 ping |
I'm accessing So i have some pretty innocent looking code like this...
that throws I also use some abstraction on top of message sender/handler for large messages. For such message service bus message body is null and content is stored as azure blob (only blob SAS uri is stored in message |
When it comes to abstraction like the one you've mentioned, it should play by the rules of the ASB client. Which is expecting a message sent out to be delivered and received with the contents. Sounds like the abstraction you're using is not doing that, causing message body to be null and therefore breaking the assumption client is making. Are you using ServiceBus.AttachmentPlugin by any chance? If you are, it's a plugin that should be registered on both, sending and receiving ends, ensuring the content of the message is rehydrated. That's why I think there's something off about this request. The entire message is either a valid message, or nothing ( |
I'm not using AttachmentPlugin but some inhouse abstraction that uses streams to handle large content so I was supprised by this behaviour when migrating code from Microsoft.ServiceBus.Messaging / BrokeredMessage where this was completely ok. I can easily adapt/workaround to this. I'm just reporting this was pretty unexpected from someone who used this library. For me it's supprising that this code throws
yet it's completely valid to create/send/receive such message, just invalid to access it's |
In case I'm looking at it from a different perspective. The old library returned zero when no body was provided. In that way, this is a regression from the expected behaviour when upgrading from the old client. Based on that, this would be categorized as a bug. |
Actual Behavior
When accessing empty message (
message.Body
is null) size propertyNullReferenceException
is thrown.Expected Behavior
Getting NullReferenceException was pretty unexpected. I would expect to get either 0 size or size of message properties
Versions
nuget 3.3.0 / netstandard2
The text was updated successfully, but these errors were encountered: