From c3524b9d3b8579f1aa79bf8c123299a94f4dcc18 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 20 Nov 2017 14:00:32 +0100 Subject: Use InetAddresses.forString instead of InetAddress.getByName Unlike InetAddress.getByName(), Guava's InetAddresses.forString() never cause DNS services to be accessed. JDK equivalents whenever you are expecting to handle only IP address string literals, so there is no blocking DNS penalty for a malformed string. See: https://google.github.io/guava/releases/22.0/api/docs/com/google/common/net/InetAddresses.html#forString-java.lang.String- Change-Id: I7972c09f1f0a3a2688021302acbf6df112be7f72 Signed-off-by: Marek Gradzki --- .../io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java | 9 ++++----- .../io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java | 9 ++++----- .../fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'v3po') diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java index 806da6858..fe0429b2b 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.google.common.collect.Lists; +import com.google.common.net.InetAddresses; import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager; @@ -36,8 +37,6 @@ import io.fd.vpp.jvpp.core.dto.GreTunnelDetails; import io.fd.vpp.jvpp.core.dto.GreTunnelDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.GreTunnelDump; import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; -import java.net.InetAddress; -import java.net.UnknownHostException; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState; @@ -68,7 +67,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest { } @Override - public void setUp() throws UnknownHostException, VppInvocationException, ReadFailedException { + public void setUp() throws VppInvocationException, ReadFailedException { interfacesContext = new NamingContext("gre-tunnel", IFC_CTX_NAME); defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME); @@ -80,8 +79,8 @@ public class GreCustomizerTest extends ReaderCustomizerTest { final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump(); final GreTunnelDetails greTunnelDetails = new GreTunnelDetails(); greTunnelDetails.isIpv6 = 0; - greTunnelDetails.dstAddress = InetAddress.getByName("1.2.3.4").getAddress(); - greTunnelDetails.srcAddress = InetAddress.getByName("1.2.3.5").getAddress(); + greTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress(); + greTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress(); greTunnelDetails.outerFibId = 55; greTunnelDetails.swIfIndex = 0; value.greTunnelDetails = Lists.newArrayList(greTunnelDetails); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java index ba0cf2d2d..bfeb7eaa9 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.google.common.collect.Lists; +import com.google.common.net.InetAddresses; import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager; @@ -36,8 +37,6 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails; import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump; -import java.net.InetAddress; -import java.net.UnknownHostException; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState; @@ -69,7 +68,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest