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

NPE if a received message is marked as "Redelivered" but no header is given #325

Closed
chbriem opened this issue Oct 4, 2023 · 2 comments · Fixed by #327
Closed

NPE if a received message is marked as "Redelivered" but no header is given #325

chbriem opened this issue Oct 4, 2023 · 2 comments · Fixed by #327
Assignees
Labels
Milestone

Comments

@chbriem
Copy link
Contributor

chbriem commented Oct 4, 2023

Describe the bug

When receiving a message in "amqp mode" with a "Redelivered" flag set, and the given message does not contain any headers, then a NPE is thrown.

Reproduction steps

  1. Initialize the "RMQDestination" with Routing Key and Exchange Name ("amqp mode").
  2. Put a message in the queue, with "relivered" flag set and no headers.
  3. Try to receive the message

Expected behavior

No NPE is thrown, and the code runs into the branch where deliveryCount == null, which sets the JMSXDeliveryCount is set to "2".

Additional context

Stacktrace (shortened):

java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because the return value of "com.rabbitmq.client.AMQP$BasicProperties.getHeaders()" is null
	at com.rabbitmq.jms.client.RMQMessage.handleJmsRedeliveredAndDeliveryCount(RMQMessage.java:886) ~[rabbitmq-jms.jar:2.8.0]
	at com.rabbitmq.jms.client.RMQMessage.convertAmqpMessage(RMQMessage.java:866) ~[rabbitmq-jms.jar:2.8.0]
	at com.rabbitmq.jms.client.RMQMessage.convertMessage(RMQMessage.java:835) ~[rabbitmq-jms.jar:2.8.0]
	at com.rabbitmq.jms.client.RMQMessageConsumer.receive(RMQMessageConsumer.java:358) ~[rabbitmq-jms.jar:2.8.0]
	at com.rabbitmq.jms.client.RMQMessageConsumer.receive(RMQMessageConsumer.java:272) ~[rabbitmq-jms.jar:2.8.0]
@chbriem chbriem added the bug label Oct 4, 2023
@lukebakken
Copy link

Thanks for using RabbitMQ.

What would expedite a fix is for us to easily be able to reproduce this issue. I am not a Java or JMS expert, but if you provided a project I could clone, compile, and run to see the issue, I could probably fix it in this code. It would take me at least an hour, probably several, to figure out how to set up a project to reproduce this issue. That's time I could be using to fix the issue.

Or, feel free to submit a PR yourself!

@lukebakken lukebakken self-assigned this Oct 4, 2023
@michaelklishin
Copy link
Member

This client assumes that the value is always set because it is always set by RabbitMQ itself (to false by default).

There's no harm in being more defensive, you are welcome to submit a PR. This is open source software after all.

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

Successfully merging a pull request may close this issue.

4 participants