From a97b280dc8f86222af52cdf33c9cdde61068a0d8 Mon Sep 17 00:00:00 2001 From: Peter Norval Date: Tue, 19 May 2020 16:47:08 +0100 Subject: [PATCH] Switched PortUtil to use getLoopbackAddress We reuse the MemcachedDaemonFactory within our application tests. However, when run from our corporate network the PortUtil fails to bind to any addresses because of the VPN being used. Under the hood the VPN doesn't resole InetAddress.getLocalHost() to the address of your local machine and hence fails to bind ports. I've updated it to using InetAddress.getLoopbackAddress() to overcome this. --- .../greencheek/caching/herdcache/memcached/util/PortUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/greencheek/caching/herdcache/memcached/util/PortUtil.java b/src/test/java/org/greencheek/caching/herdcache/memcached/util/PortUtil.java index 3dc857e..b172bc8 100644 --- a/src/test/java/org/greencheek/caching/herdcache/memcached/util/PortUtil.java +++ b/src/test/java/org/greencheek/caching/herdcache/memcached/util/PortUtil.java @@ -11,7 +11,7 @@ public class PortUtil { public static ServerSocket findFreePort() { ServerSocket server = null; try { - server = new ServerSocket(0,1000, InetAddress.getLocalHost()); + server = new ServerSocket(0,1000, InetAddress.getLoopbackAddress()); server.setReuseAddress(true); } catch (IOException e) { e.printStackTrace();