Description
In what version(s) of Spring AMQP are you seeing this issue?
2.4.6, but current main branch is also affected
Describe the bug
The following line can produce NPE:
as according to the documentation of ShutdownSignalException.getReason()
: "the reason, if any". Under some circumstances, like a low-level TCP Connection Reset on the connection, the Rabbit client library will not fill in the reason in the exception, therefore this code will throw NPE and connection listeners will not be called.
To Reproduce
To reproduce:
- set up a
ConnectionListener
on a ConnectionFactory (likeCachingConnectionFactory
) - establish connection to a RabbitMQ server
- force the TCP connection to RST via some networking/os tools. I used Linux and forced the connection to break using
sudo iptables -A INPUT -p tcp --dport 5672 -j REJECT --reject-with tcp-reset
Expected behavior
The ConnectionListener
's onShutdown(cause)
should be called. If the Reason does not define channel, then connection-level problem should be assumed.
Sample
I can create a sample if really required but based on the linked source code line it is clearly visible that NPE is possible.