Skip to content

NPE in AbstractConnectionFactory that causes connection listeners to be skipped #2425

Closed
@deje07

Description

@deje07

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:

  1. set up a ConnectionListener on a ConnectionFactory (like CachingConnectionFactory)
  2. establish connection to a RabbitMQ server
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions