@Override
  public Optional<InetAddress> getLocalInetAddress(Predicate<InetAddress> predicate) {
    try {
      return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()
        .flatMap(ni -> Collections.list(ni.getInetAddresses()).stream())
        .filter(a -> a.getHostAddress() != null)
        .filter(predicate)
        .findFirst();
    } catch (SocketException e) {
      LOG.trace("getLocalInetAddress(Predicate<InetAddress>) failed", e);
      throw new IllegalStateException("Can not retrieve network interfaces", e);
    }
  }
@Test
  public void getLocalInetAddress_filters_local_addresses() {
    InetAddress address = underTest.getLocalInetAddress(InetAddress::isLoopbackAddress).get();
    assertThat(address.isLoopbackAddress()).isTrue();
  }