From 35aae4e96fc272719f3845f7e8d4894db3a4c5af Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 12 Feb 2016 18:14:08 +0100 Subject: Use Guava's int-toipv4 primitive Guava has a neat utility to perform the conversion, use that instead of open-coding it. Change-Id: Ifa8d79845950faccc3433b84e42dc2ba08828248 Signed-off-by: Robert Varga --- .../main/java/io/fd/honeycomb/v3po/impl/V3poApiRequest.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'v3po/impl/src') diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poApiRequest.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poApiRequest.java index 9eb9d3a08..b4f3fe93f 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poApiRequest.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poApiRequest.java @@ -16,6 +16,7 @@ package io.fd.honeycomb.v3po.impl; +import com.google.common.net.InetAddresses; import com.google.common.primitives.Ints; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; @@ -168,15 +169,7 @@ public class V3poApiRequest extends V3poRequest { } private static String ipv4IntToString(final int ip) { - InetAddress addr = null; - byte[] bytes = Ints.toByteArray(ip); - try { - addr = InetAddress.getByAddress(bytes); - } catch (java.net.UnknownHostException e) { - e.printStackTrace(); - return null; - } - return addr.getHostAddress(); + return InetAddresses.fromInteger(ip).getHostAddress(); } private Interface buildStateInterface(final int ifIndex, @@ -197,7 +190,7 @@ public class V3poApiRequest extends V3poRequest { final int vtrTag1, final int vtrTag2, final Statistics stats) { InterfaceBuilder ifBuilder = new InterfaceBuilder(); - java.lang.Class ifType; + Class ifType; // FIXME: missing types for virtualethernet, subinterface, tap interface etc if (interfaceName.startsWith("loop")) { -- cgit 1.2.3-korg