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

NullReference Exception on Enqueuing #35

Open
jamescurran opened this issue Oct 22, 2020 · 3 comments
Open

NullReference Exception on Enqueuing #35

jamescurran opened this issue Oct 22, 2020 · 3 comments
Labels

Comments

@jamescurran
Copy link

It seems that commit fe221fb from April inserted a bug into the code. Now a simple

await _queueClient.EnqueueAsync(message);

will throw an exception. The problem is at AzureServiceBusQueue.cs (114)

foreach (var property in options.Properties)
    brokeredMessage.UserProperties[property.Key] = property.Value;

The problem is, unless options are explicitly set, the Properties property is null.

The proper fix, I believe, is to change IQueue.cs(69) from

public class QueueEntryOptions {
    public string CorrelationId { get; set; }
    public DataDictionary Properties { get; set; }
}

to

public class QueueEntryOptions {
    public string CorrelationId { get; set; }
    public DataDictionary Properties { get; set; } = new DataDictionary();
}

(I'm working on a pull request for that)

In the meantime, the workaround is to include the options with the Properties defined:

 private static readonly QueueEntryOptions _dummyOptions = new QueueEntryOptions {Properties = new DataDictionary()};
 // :
 // :
await _queueClient.EnqueueAsync(message, _dummyOptions);
@niemyjski
Copy link
Member

niemyjski commented Oct 22, 2020

Great find! I think that is the proper fix and we'll merge in that pr ASAP. I'm guessing this passed our unit tests due to they all use options.

@niemyjski niemyjski added the bug label Oct 22, 2020
@ejsmith
Copy link
Contributor

ejsmith commented Oct 22, 2020

Sorry about that @jamescurran. Thank you for reporting it!

@jamescurran
Copy link
Author

I'm guessing this passed our unit tests due to they all use options.

Well.... See issue #36 If you don't set the connection string, all tests all appear to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants