1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-10-31 17:25:58 +01:00

Fix IllegalArgumentException on DNS lookup if XMPP domain is wrong

Fixes the following exception thrown if the user had entered a non-existend XMPP domain:
java.lang.IllegalArgumentException: Must provide at least one InetAddress
     at org.jivesoftware.smack.util.dns.HostAddress.<init>(HostAddress.java:55)
     at org.jivesoftware.smack.util.dns.DNSResolver.lookupHostAddress(DNSResolver.java: 56)
     at org.jivesoftware.smack.util.DNSUtil.resolveDomain(DNSUtil.java:209)
     at org.jivesoftware.smack.util.DNSUtil.resolveXMPPServiceDomain(DNSUtil.java:136)
     at org.jivesoftware.smack.AbstractXMPPConnection.populateHostAddresses(AbstractXMP PConnection.java:626)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:556)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:888)
     at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:377)

Thanks to Grigory Fedorov for reporting.
This commit is contained in:
Florian Schmaus 2017-01-12 13:39:11 +01:00
parent 9d8caf0563
commit f31cc6e043

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2016 Florian Schmaus
* Copyright 2013-2017 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -50,7 +50,7 @@ public abstract class DNSResolver {
public final HostAddress lookupHostAddress(String name, int port, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
checkIfDnssecRequestedAndSupported(dnssecMode);
List<InetAddress> inetAddresses = lookupHostAddress0(name, failedAddresses, dnssecMode);
if (inetAddresses == null) {
if (inetAddresses == null || inetAddresses.isEmpty()) {
return null;
}
return new HostAddress(name, port, inetAddresses);