From f31cc6e043410d9b81d969622354261751033d1e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 12 Jan 2017 13:39:11 +0100 Subject: [PATCH] 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.(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. --- .../java/org/jivesoftware/smack/util/dns/DNSResolver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java b/smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java index dde188959..79de3e08a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java @@ -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 failedAddresses, DnssecMode dnssecMode) { checkIfDnssecRequestedAndSupported(dnssecMode); List inetAddresses = lookupHostAddress0(name, failedAddresses, dnssecMode); - if (inetAddresses == null) { + if (inetAddresses == null || inetAddresses.isEmpty()) { return null; } return new HostAddress(name, port, inetAddresses);