Skip to content

Commit

Permalink
Fix by reference comparison for review
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Sep 4, 2023
1 parent ddfa799 commit e867e91
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/freenet/support/io/InetAddressIpv6FirstComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public class InetAddressIpv6FirstComparator implements Comparator<InetAddress> {

@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()) {
Expand Down

0 comments on commit e867e91

Please sign in to comment.