diff --git a/src/main/java/com/nextcloud/common/IPV6PreferringDNS.java b/src/main/java/com/nextcloud/common/IPV6PreferringDNS.java index 1e8f68242..632436b11 100644 --- a/src/main/java/com/nextcloud/common/IPV6PreferringDNS.java +++ b/src/main/java/com/nextcloud/common/IPV6PreferringDNS.java @@ -3,12 +3,13 @@ import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; + import okhttp3.Dns; /** @@ -16,19 +17,19 @@ */ public class IPV6PreferringDNS implements Dns { - private Map> cache = new HashMap<>(); + private Map> cache = new HashMap<>(); @Override public List lookup(String hostname) throws UnknownHostException { - List addresses = cache.get(hostname.toLowerCase(Locale.ROOT)); + ArrayList addresses = cache.get(hostname.toLowerCase(Locale.ROOT)); if (addresses != null) { return addresses; } - addresses = Dns.SYSTEM.lookup(hostname); + addresses = new ArrayList<>(Dns.SYSTEM.lookup(hostname)); Collections.sort(addresses, (address1, address2) -> { - if(address1 instanceof Inet4Address) { + if (address1 instanceof Inet4Address) { return 1; } else { return -1; @@ -38,4 +39,4 @@ public List lookup(String hostname) throws UnknownHostException { return addresses; } - } \ No newline at end of file + }