diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index bf7897f9f8b..aa8a29cb082 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -125,20 +125,16 @@ IceInternal::TcpEndpointI::datagram() const shared_ptr IceInternal::TcpEndpointI::toPublishedEndpoint(string publishedHost) const { - if (publishedHost.empty() && !isAddressValid(_sourceAddr) && _connectionId.empty()) + // A server endpoint can't have a source address or connection ID. + assert(!isAddressValid(_sourceAddr) && _connectionId.empty()); + + if (publishedHost.empty()) { return const_cast(this)->shared_from_this(); } else { - return make_shared( - _instance, - publishedHost.empty() ? _host : publishedHost, - _port, - Address{}, - _timeout, - "", - _compress); + return make_shared(_instance, publishedHost, _port, Address{}, _timeout, "", _compress); } } diff --git a/csharp/src/Ice/Internal/TcpEndpointI.cs b/csharp/src/Ice/Internal/TcpEndpointI.cs index 415f831e5e2..e79578fad93 100644 --- a/csharp/src/Ice/Internal/TcpEndpointI.cs +++ b/csharp/src/Ice/Internal/TcpEndpointI.cs @@ -214,20 +214,16 @@ public override void fillEndpointInfo(Ice.IPEndpointInfo info) public override EndpointI toPublishedEndpoint(string publishedHost) { - if (publishedHost.Length == 0 && sourceAddr_ is null && connectionId_.Length == 0) + // A server endpoint can't have a source address or connection ID. + Debug.Assert(sourceAddr_ is null && connectionId_.Length == 0); + + if (publishedHost.Length == 0) { return this; } else { - return new TcpEndpointI( - instance_, - publishedHost.Length > 0 ? publishedHost : host_, - port_, - sourceAddr: null, - _timeout, - conId: "", - _compress); + return new TcpEndpointI(instance_, publishedHost, port_, sourceAddr: null, _timeout, conId: "", _compress); } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java index eb2671983bf..d5d29ca3c51 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java @@ -215,17 +215,12 @@ public int hashCode() { @Override public EndpointI toPublishedEndpoint(String publishedHost) { - if (publishedHost.isEmpty() && _sourceAddr == null && _connectionId.isEmpty()) { + // A server endpoint can't have a source address or connection ID. + assert (_sourceAddr == null && _connectionId.isEmpty()); + if (publishedHost.isEmpty()) { return this; } else { - return new TcpEndpointI( - _instance, - publishedHost.isEmpty() ? _host : publishedHost, - _port, - null, - _timeout, - "", - _compress); + return new TcpEndpointI(_instance, publishedHost, _port, null, _timeout, "", _compress); } }