1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Deal with cases wehre HostAddress.fqdn is null

Fixes SMACK-772
This commit is contained in:
Florian Schmaus 2017-07-02 18:09:15 +02:00
parent 813219179f
commit 3d032298a5
2 changed files with 20 additions and 4 deletions

View file

@ -75,6 +75,22 @@ public class HostAddress {
setException(e);
}
public String getHost() {
if (fqdn != null) {
return fqdn;
}
// In this case, the HostAddress(int, InetAddress) constructor must been used. We have no FQDN. And
// inetAddresses.size() must be exactly one.
assert inetAddresses.size() == 1;
return inetAddresses.get(0).getHostAddress();
}
/**
* Return the fully qualified domain name. This may return <code>null</code> in case there host address is only numeric, i.e. an IP address.
*
* @return the fully qualified domain name or <code>null</code>
*/
public String getFQDN() {
return fqdn;
}
@ -109,7 +125,7 @@ public class HostAddress {
@Override
public String toString() {
return fqdn + ":" + port;
return getHost() + ":" + port;
}
@Override
@ -123,7 +139,7 @@ public class HostAddress {
final HostAddress address = (HostAddress) o;
if (!fqdn.equals(address.fqdn)) {
if (!getHost().equals(address.getHost())) {
return false;
}
return port == address.port;
@ -132,7 +148,7 @@ public class HostAddress {
@Override
public int hashCode() {
int result = 1;
result = 37 * result + fqdn.hashCode();
result = 37 * result + getHost().hashCode();
return result * 37 + port;
}

View file

@ -563,7 +563,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
}
for (HostAddress hostAddress : hostAddresses) {
Iterator<InetAddress> inetAddresses = null;
String host = hostAddress.getFQDN();
String host = hostAddress.getHost();
int port = hostAddress.getPort();
if (proxyInfo == null) {
inetAddresses = hostAddress.getInetAddresses().iterator();