Skip to content

Commit 2c0f2fa

Browse files
committed
Null-proof peer address in observation collection
Fixes #1534 (cherry picked from commit c992041)
1 parent 3ded289 commit 2c0f2fa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/rabbitmq/client/impl/AMQConnection.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ public void start()
442442
setHeartbeat(heartbeat);
443443

444444
this.connectionInfo = new DefaultConnectionInfo(
445-
this._frameHandler.getAddress().getHostAddress(),
446-
this._frameHandler.getPort()
445+
getAddress(),
446+
getPort()
447447
);
448448

449449
_channel0.transmit(new AMQP.Connection.TuneOk.Builder()
@@ -1236,13 +1236,13 @@ private static class DefaultConnectionInfo implements ObservationCollector.Conne
12361236
private final String peerAddress;
12371237
private final int peerPort;
12381238

1239-
private DefaultConnectionInfo(String peerAddress, int peerPort) {
1240-
this.peerAddress = peerAddress;
1239+
private DefaultConnectionInfo(InetAddress address, int peerPort) {
1240+
this.peerAddress = address == null ? "" : (address.getHostAddress() == null ? "" : address.getHostAddress());
12411241
this.peerPort = peerPort;
12421242
}
12431243

12441244
@Override
1245-
public String getPeerAddress() {
1245+
public String getPeerAddress() {
12461246
return peerAddress;
12471247
}
12481248

0 commit comments

Comments
 (0)