Skip to content

NullPointerException since 5.19.0 (Add support for Micrometer Observation) #1534

Closed
@assopt

Description

@assopt

Describe the bug

java.lang.NullPointerException: Cannot invoke "java.net.InetAddress.getHostAddress()" because the return value of "com.rabbitmq.client.impl.FrameHandler.getAddress()" is null
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:445)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1251)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198)
        ...

The code at line 445 was added in 5.19.0 (Add support for Micrometer Observation).

Other code in the class AMQConnection is null safe. toString() for example uses the method getHostAddress() which explicitly handles the case of the address being null.

Reproduction steps

We know that the address is null because the hostname cannot be resolved. As we have a proxy in between there is no need to resolve the hostname in the first place.

Expected behavior

No NPE even if the hostname cannot be resolved to an address.

Use getHostAddress() instead of this._frameHandler.getAddress().getHostAddress().

Additional context

Including 5.18.0 everything worked. With the update to a newer version as the only change on our side we get the NPE.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions