diff options
4 files changed, 12 insertions, 11 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java index acd640002fa..310c7ceeef7 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Version; import com.yahoo.jrt.Request; import com.yahoo.log.LogLevel; -import com.yahoo.net.LinuxInetAddress; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.ConfigPayload; import com.yahoo.vespa.config.ErrorCode; import com.yahoo.vespa.config.UnknownConfigIdException; @@ -27,7 +27,7 @@ import java.util.logging.Logger; class GetConfigProcessor implements Runnable { private static final Logger log = Logger.getLogger(GetConfigProcessor.class.getName()); - private static final String localHostName; + private static final String localHostName = HostName.getLocalhost(); private final JRTServerConfigRequest request; /* True only when this request has expired its server timeout and we need to respond to the client */ @@ -151,14 +151,6 @@ class GetConfigProcessor implements Runnable { respond(request); } - /** - * Done in a static block to prevent people invoking this directly. - * Do not call java.net.Inet4AddressImpl.getLocalHostName() on each request, as this causes CPU bottlenecks. - */ - static { - localHostName = LinuxInetAddress.getLocalHost().getHostName(); - } - static boolean logDebug(Trace trace) { return trace.shouldTrace(RpcServer.TRACELEVEL_DEBUG) || log.isLoggable(LogLevel.DEBUG); } diff --git a/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java b/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java index c3e74ddce3d..52a66fa6db9 100644 --- a/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java +++ b/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; @@ -13,6 +14,7 @@ import java.nio.ByteBuffer; import java.util.logging.Logger; import com.yahoo.container.search.Fs4Config; +import com.yahoo.net.HostName; import com.yahoo.net.LinuxInetAddress; import com.yahoo.prelude.fastsearch.FS4ResourcePool; import org.junit.After; @@ -111,7 +113,8 @@ public class BackendTestCase { public MockDispatch dispatch; public MockServer() throws IOException { - ServerSocket socket = new ServerSocket(0, 50, LinuxInetAddress.getLocalHost()); + ServerSocket socket = new ServerSocket(0, 50, InetAddress.getLoopbackAddress()); + //ServerSocket socket = new ServerSocket(0, 50, LinuxInetAddress.getLocalHost()); host = (InetSocketAddress) socket.getLocalSocketAddress(); dispatch = new MockDispatch(socket); worker = new Thread(dispatch); diff --git a/vespajlib/src/main/java/com/yahoo/net/LinuxInetAddress.java b/vespajlib/src/main/java/com/yahoo/net/LinuxInetAddress.java index 6943723576f..1b7658b3a11 100644 --- a/vespajlib/src/main/java/com/yahoo/net/LinuxInetAddress.java +++ b/vespajlib/src/main/java/com/yahoo/net/LinuxInetAddress.java @@ -18,6 +18,7 @@ import java.util.stream.Collectors; * * @author bratseth */ +// TODO: Remove on vespa 7 public class LinuxInetAddress { /** @@ -27,10 +28,12 @@ public class LinuxInetAddress { * IPv4 is preferred over IPv6 among resolving addresses. * * @return a localhost address + * @deprecated use {@link HostName} instead */ // Note: Checking resolvability of ipV6 addresses takes a long time on some systems (over 5 seconds // for some addresses on my mac). This method is written to minimize the number of resolution checks done // and to defer ip6 checks until necessary. + @Deprecated public static InetAddress getLocalHost() { InetAddress fallback = InetAddress.getLoopbackAddress(); try { @@ -67,7 +70,9 @@ public class LinuxInetAddress { * * @return an array of the addresses of this * @throws UnknownHostException if we cannot access the network + * @deprecated do not use */ + @Deprecated public static InetAddress[] getAllLocal() throws UnknownHostException { InetAddress[] localInetAddresses = InetAddress.getAllByName("127.0.0.1"); if ( ! localInetAddresses[0].isLoopbackAddress()) return localInetAddresses; diff --git a/vespajlib/src/test/java/com/yahoo/net/LinuxInetAddressTestCase.java b/vespajlib/src/test/java/com/yahoo/net/LinuxInetAddressTestCase.java index f5da8b8bfa7..27b85a0864c 100755 --- a/vespajlib/src/test/java/com/yahoo/net/LinuxInetAddressTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/net/LinuxInetAddressTestCase.java @@ -10,6 +10,7 @@ import java.net.Inet4Address; */
public class LinuxInetAddressTestCase extends junit.framework.TestCase {
+ @SuppressWarnings("deprecation")
public void testPreferIPv4() throws UnknownHostException {
try {
// This test only works if there is at least one inet address returned.
|