docs: private static InetAddress chooseAddress(String preferred) throws UnknownHostException {
          Set<InetAddress> addresses = getAddresses();
          if (preferred != null && !preferred.isEmpty()) {
              //Favor preferred address if exists
              try {
                  InetAddress preferredAddress = InetAddress.getByName(preferred);
                  if (addresses != null && addresses.contains(preferredAddress)) {
                      LOG.info("preferred address is " + preferredAddress.getHostAddress() + " for host " + preferredAddress.getHostName());
                      return preferredAddress;
                  }
              } catch (UnknownHostException e) {
                  //noop
              }
              for (InetAddress address : addresses) {
                  if (preferred.equals(address.getHostName())) {
                      return address;
                  }
              }
              StringBuffer hostNameBuffer = new StringBuffer();
              for (InetAddress address : addresses) {
                  if (hostNameBuffer.length() > 0) {
                      hostNameBuffer.append(", ");
                  }
                  hostNameBuffer.append(address.getHostName() + "/" + address.getHostAddress());
              }
              LOG.warn("Could not find network address for preferred '" + preferred + "' when the addresses were: " + hostNameBuffer);
          }
          if (addresses.contains(InetAddress.getLocalHost())) {
              //Then if local host address is not bound to a loop-back interface, use it.
              return InetAddress.getLocalHost();
          } else if (addresses != null && !addresses.isEmpty()) {
              //else return the first available addrress
              return addresses.toArray(new InetAddress[addresses.size()])[0];
          } else {
              //else we are forcedt to use the localhost address.
              return InetAddress.getLocalHost();
          }
      }