From 400d67a03b774033cfd3c722ac1a29bccb9a4493 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 4 May 2021 10:57:18 +0200 Subject: [PATCH] Use ArrayList instead of List, as some lists are not sortable Signed-off-by: tobiasKaminsky --- .../com/nextcloud/common/IPV6PreferringDNS.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 + }