rabbitmq-dotnet-client icon indicating copy to clipboard operation
rabbitmq-dotnet-client copied to clipboard

IsHeadersPresent() throws NullReferenceException in 5.2 and 6.8.1

Open MartinBring opened this issue 7 months ago • 0 comments

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

  1. Open a connection
  2. Start one channel with an and inputlistener to a queue
  3. Put a message without headers on a queue.
  4. Read from queue with Take()
  5. Use Message.BasicProperties.IsHeadersPresent() to check for headers.
  6. It will return false, no Exception occurs

Not working

  1. Close the first connection
  2. Start two new ones, each with a channel and inputlistener to different queues
  3. Put a message without headers on one of the queues.
  4. Read from queue with Take()
  5. Use Message.BasicProperties.IsHeadersPresent() to check for headers.
  6. 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

MartinBring avatar Jul 03 '24 11:07 MartinBring