Details
Description
TcpTransportServer's instance variable 'connectURI' is initialised when the socket is bound. If the address is ANY ADDRESS (0.0.0.0) in a multi-NIC machine, the socket is bound to all NICs, but only a single connect URI is registered.
InetAddressUtil.getLocalHostName() is invoked to calculate the connect URI.
The connectURI is used to represent the current broker when the list of peers is populated as part of the updateClusterClients feature.
In real life, a client transport connection could come in from any NIC, where each NIC has a different hostname. So it's easy to send back a wrong hostname in the updated list to the client.
I propose a solution comprised of the following changes:
- Remember the actual connect URI for each individual transport connection and use that for the current broker in the updated connect list.
- Turn the connectURI variable on TcpTransportServer into a List<String>.