mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02:06 +01:00
Return empty list instead of null in DNSUtil
This commit is contained in:
parent
42d0557682
commit
c59a6010e1
1 changed files with 3 additions and 4 deletions
|
@ -122,8 +122,7 @@ 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
|
||||||
addresses.add(new HostAddress(domain));
|
addresses.add(new HostAddress(domain));
|
||||||
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue