Skip to content

NullReference Exception on Enqueuing #35

Open
@jamescurran

Description

@jamescurran

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions