diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 66c314524d..17e8c5ecea 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -22,8 +22,12 @@ public class InetAddressIpv6FirstComparator implements Comparator { @Override public int compare(InetAddress arg0, InetAddress arg1) { - if(arg0 == arg1) return 0; - // prefer everything over broadcast + if ((arg0 == null && arg1 == null)) return 0; + // prefer non-null over null + if (arg0 == null) return 1; + if (arg1 == null) return -1; + if(arg0.equals(arg1)) return 0; + // prefer everything to broadcast if (!arg0.isAnyLocalAddress() && arg1.isAnyLocalAddress()) { return -1; } else if (arg0.isAnyLocalAddress() && !arg1.isAnyLocalAddress()) {