Skip to content

Commit

Permalink
add set cache method
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Oct 17, 2024
1 parent 3d68854 commit 28effac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/org/jgroups/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,14 @@ public static void resetCacheAddresses(boolean reset_interfaces, boolean reset_a
CACHED_ADDRESSES=null;
}

/** This is a workaround for use within android. Sometimes the standard java methods do not return all the addresses.
* This will allow for setting in android via the conectivity manager without needing to pass in the context.
* Also will allow android to update as connectivity changes.
*/
public static void setCacheAddresses(List<NetworkInterface> interfaces, List<InetAddress> addresses) {
CACHED_INTERFACES=interfaces;
CACHED_ADDRESSES=addresses;
}
/** Returns all addresses of all interfaces (that are up) that satisfy a given filter (ignored if null) */
public static Collection<InetAddress> getAllAvailableAddresses(Predicate<InetAddress> filter) {
Collection<InetAddress> cached_addresses=getAllAvailableAddresses();
Expand Down

0 comments on commit 28effac

Please sign in to comment.