Skip to content

Commit c992041

Browse files
committed
Null-proof peer address in observation collection
Fixes #1534
1 parent af447a7 commit c992041

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/main/java/com/rabbitmq/client/impl/AMQConnection.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ public void start()
433433
setHeartbeat(negotiatedHeartbeat);
434434

435435
this.connectionInfo = new DefaultConnectionInfo(
436-
this._frameHandler.getAddress().getHostAddress(),
437-
this._frameHandler.getPort()
436+
getAddress(),
437+
getPort()
438438
);
439439

440440
_channel0.transmit(new AMQP.Connection.TuneOk.Builder()
@@ -1225,13 +1225,13 @@ private static class DefaultConnectionInfo implements ObservationCollector.Conne
12251225
private final String peerAddress;
12261226
private final int peerPort;
12271227

1228-
private DefaultConnectionInfo(String peerAddress, int peerPort) {
1229-
this.peerAddress = peerAddress;
1228+
private DefaultConnectionInfo(InetAddress address, int peerPort) {
1229+
this.peerAddress = address == null ? "" : (address.getHostAddress() == null ? "" : address.getHostAddress());
12301230
this.peerPort = peerPort;
12311231
}
12321232

12331233
@Override
1234-
public String getPeerAddress() {
1234+
public String getPeerAddress() {
12351235
return peerAddress;
12361236
}
12371237

0 commit comments

Comments
 (0)