From c59a6010e193eb46d090c60ea1c3002d7136194e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 26 Mar 2014 22:48:32 +0100 Subject: [PATCH] Return empty list instead of null in DNSUtil --- .../src/main/java/org/jivesoftware/smack/util/DNSUtil.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java b/core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java index 4430e9bba..83e0499f4 100644 --- a/core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java +++ b/core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java @@ -122,8 +122,7 @@ public class DNSUtil { } List srvRecords = dnsResolver.lookupSRVRecords(srvDomain); List sortedRecords = sortSRVRecords(srvRecords); - if (sortedRecords != null) - addresses.addAll(sortedRecords); + addresses.addAll(sortedRecords); // Step two: Add the hostname to the end of the list addresses.add(new HostAddress(domain)); @@ -139,11 +138,11 @@ public class DNSUtil { * @param records * @return the list of resolved HostAddresses */ - protected static List sortSRVRecords(List records) { + private static List sortSRVRecords(List records) { // RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "." // (the root domain), abort." if (records.size() == 1 && records.get(0).getFQDN().equals(".")) - return null; + return Collections.emptyList(); // sorting the records improves the performance of the bisection later Collections.sort(records);