class NetworkExt {

    public static Optional<List<String>> getLocalIPs(boolean ipv4Only) {
        if (resolvedLocalIPsRef.get() == null) {
            try {
                resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only)));
            } catch (Exception e) {
                logger.error("Cannot resolve local IP addresses");
                resolvedLocalIPsRef.set(Optional.empty());
            }
        }
        return resolvedLocalIPsRef.get();
    }

}