mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 13:32:07 +01:00
Deal with cases wehre HostAddress.fqdn is null
Fixes SMACK-772
This commit is contained in:
parent
813219179f
commit
3d032298a5
2 changed files with 20 additions and 4 deletions
|
@ -75,6 +75,22 @@ public class HostAddress {
|
||||||
setException(e);
|
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() {
|
public String getFQDN() {
|
||||||
return fqdn;
|
return fqdn;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +125,7 @@ public class HostAddress {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fqdn + ":" + port;
|
return getHost() + ":" + port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,7 +139,7 @@ public class HostAddress {
|
||||||
|
|
||||||
final HostAddress address = (HostAddress) o;
|
final HostAddress address = (HostAddress) o;
|
||||||
|
|
||||||
if (!fqdn.equals(address.fqdn)) {
|
if (!getHost().equals(address.getHost())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return port == address.port;
|
return port == address.port;
|
||||||
|
@ -132,7 +148,7 @@ public class HostAddress {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = 37 * result + fqdn.hashCode();
|
result = 37 * result + getHost().hashCode();
|
||||||
return result * 37 + port;
|
return result * 37 + port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -563,7 +563,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
for (HostAddress hostAddress : hostAddresses) {
|
for (HostAddress hostAddress : hostAddresses) {
|
||||||
Iterator<InetAddress> inetAddresses = null;
|
Iterator<InetAddress> inetAddresses = null;
|
||||||
String host = hostAddress.getFQDN();
|
String host = hostAddress.getHost();
|
||||||
int port = hostAddress.getPort();
|
int port = hostAddress.getPort();
|
||||||
if (proxyInfo == null) {
|
if (proxyInfo == null) {
|
||||||
inetAddresses = hostAddress.getInetAddresses().iterator();
|
inetAddresses = hostAddress.getInetAddresses().iterator();
|
||||||
|
|
Loading…
Reference in a new issue