From 940956e1513837842a780152fc1db837afea1864 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Thu, 21 Jun 2018 08:39:59 +0200 Subject: Fix NPE in InterfaceDataTranslator.isInterfaceOfType SwInterfaceDetails returned by dump manager are nullable. In that case isInterfaceOfType should return false. Change-Id: Iaf3d1f6c6923ed6863357fe2470716f135b6164f Signed-off-by: Marek Gradzki --- .../hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'v3po/v3po2vpp/src/main') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java index 9f788afc6..75554d4b7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java @@ -29,6 +29,7 @@ import java.math.BigInteger; import java.util.Objects; import java.util.stream.Collector; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; @@ -177,9 +178,13 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo return isInterfaceOfType(ifcType, vppInterfaceDetails); } - default boolean isInterfaceOfType(final Class ifcType, - final SwInterfaceDetails cachedDetails) { - return ifcType.equals(getInterfaceType(toString(cachedDetails.interfaceName))); + default boolean isInterfaceOfType(@Nonnull final Class ifcType, + @Nullable final SwInterfaceDetails cachedDetails) { + if (cachedDetails == null) { + return false; + } else { + return ifcType.equals(getInterfaceType(toString(cachedDetails.interfaceName))); + } } /** -- cgit 1.2.3-korg