rabbitmq-dotnet-client
rabbitmq-dotnet-client copied to clipboard
IsHeadersPresent() throws NullReferenceException in 5.2 and 6.8.1
Describe the bug
Message.BasicProperties.IsHeadersPresent()
throws NullReferenceException sometimes (often), and sometimes not. It happens both in 5.2 and 6.8.1. It can have to do something how connections, channels, model are opened/closed. We experience that it doesn't happen with only one listener, but always after closing that one and starting two new connections/channels/listerners. Excuse me for not providing more information than this, i'm not that familiar with the area.
Reproduction steps
Working
- Open a connection
- Start one channel with an and inputlistener to a queue
- Put a message without headers on a queue.
- Read from queue with Take()
- Use Message.BasicProperties.IsHeadersPresent() to check for headers.
- It will return false, no Exception occurs
Not working
- Close the first connection
- Start two new ones, each with a channel and inputlistener to different queues
- Put a message without headers on one of the queues.
- Read from queue with Take()
- Use Message.BasicProperties.IsHeadersPresent() to check for headers.
- NullReferenceException will occur
Expected behavior
IsHeadersPresent() should return true or false, not throw any exception.
Additional context
We now check the actual headers for null and Count > 0
queueMessage.BasicProperties.Headers != null && queueMessage.BasicProperties.Headers.Count > 0