code: private static String getHostIPAddressFromString(String propIPAddress, String niName) {
      String hostIPAddr = propIPAddress;
  
      if (propIPAddress.equals("")) {
        // If the listenerIPAddress is blank, then try to get the ip address of
        // the interface
  
        try {
          NetworkInterface ni = null;
          if (niName != null)
            ni = NetworkInterface.getByName(niName);
          if (ni == null) {
            LOGGER.info("Network Interface name not specified or incorrect.  Defaulting to localhost");
            hostIPAddr = InetAddress.getLocalHost().getHostAddress();
          } else {
  
            if (!ni.isLoopback()) {
  
              Enumeration<InetAddress> ee = ni.getInetAddresses();
              while (ee.hasMoreElements()) {
                InetAddress i = (InetAddress) ee.nextElement();
                if (i instanceof Inet4Address) {
                  hostIPAddr = i.getHostAddress();
                  break; // get the first one an get out of the loop
                }
              }
            }
          }
  
        } catch (SocketException e) {
          LOGGER.warn("A socket exception occurred.");
        } catch (UnknownHostException e) {
          LOGGER.warn( "Error finding Network Interface", e);
        }
  
      }
  
      return hostIPAddr;
    }
docs: /*
  provides the correct host IP address from a string (propIPAddress). This
  method takes the IP addresses from the properties file and then resolves it
  to be the correct IP address for the local host to use.
  
  The propIPAddress might be empty. In this case return the correct IP
  address for the local host and not the loopback address. This makes an
  assumption that if the user omitted the IP address from the config file,
  then just use the local host address.
  
  This handles the majority of cases where you don't know the IP address but
  want simple configuration. It's a good way to default to the local host IP
  address.
  
  @param propIPAddress the IP address from the properties file
  
  @return the value of the correct string for the local host IP address if
  the propIPAddress is empty