1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-30 02:02:06 +01:00

Return empty list instead of null in DNSUtil

This commit is contained in:
Florian Schmaus 2014-03-26 22:48:32 +01:00
parent 42d0557682
commit c59a6010e1

View file

@ -122,7 +122,6 @@ public class DNSUtil {
} }
List<SRVRecord> srvRecords = dnsResolver.lookupSRVRecords(srvDomain); List<SRVRecord> srvRecords = dnsResolver.lookupSRVRecords(srvDomain);
List<HostAddress> sortedRecords = sortSRVRecords(srvRecords); List<HostAddress> sortedRecords = sortSRVRecords(srvRecords);
if (sortedRecords != null)
addresses.addAll(sortedRecords); addresses.addAll(sortedRecords);
// Step two: Add the hostname to the end of the list // Step two: Add the hostname to the end of the list
@ -139,11 +138,11 @@ public class DNSUtil {
* @param records * @param records
* @return the list of resolved HostAddresses * @return the list of resolved HostAddresses
*/ */
protected static List<HostAddress> sortSRVRecords(List<SRVRecord> records) { private static List<HostAddress> sortSRVRecords(List<SRVRecord> records) {
// RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "." // RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "."
// (the root domain), abort." // (the root domain), abort."
if (records.size() == 1 && records.get(0).getFQDN().equals(".")) if (records.size() == 1 && records.get(0).getFQDN().equals("."))
return null; return Collections.emptyList();
// sorting the records improves the performance of the bisection later // sorting the records improves the performance of the bisection later
Collections.sort(records); Collections.sort(records);