From 1ea5caa3f6717b16fdc7c65748ef21c8e4093677 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 21 Oct 2016 08:11:53 +0200 Subject: Fix NPE in VppInitializer occuring when no BDs are configured Change-Id: Iafebdc5dcc978313daf9818907fc27b2909ecc04 Signed-off-by: Marek Gradzki --- .../v3po/initializers/VppInitializer.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'v3po/v3po2vpp/src') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java index 836a43b9d..aa8d76a37 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java @@ -16,8 +16,6 @@ package io.fd.honeycomb.translate.v3po.initializers; -import com.google.common.base.Function; -import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.honeycomb.data.init.AbstractDataTreeConverter; @@ -55,14 +53,17 @@ public class VppInitializer extends AbstractDataTreeConverter { LOG.debug("VppInitializer.convert()"); VppBuilder vppBuilder = new VppBuilder(); - BridgeDomainsBuilder bdsBuilder = new BridgeDomainsBuilder(); - bdsBuilder.setBridgeDomain(Lists.transform(operationalData.getBridgeDomains().getBridgeDomain(), CONVERT_BD)); - vppBuilder.setBridgeDomains(bdsBuilder.build()); + if (operationalData.getBridgeDomains() != null) { + BridgeDomainsBuilder bdsBuilder = new BridgeDomainsBuilder(); + bdsBuilder.setBridgeDomain(operationalData.getBridgeDomains().getBridgeDomain().stream().map(VppInitializer::convert) + .collect(Collectors.toList())); + vppBuilder.setBridgeDomains(bdsBuilder.build()); + } return vppBuilder.build(); } - private static final Function - CONVERT_BD = input -> { + private static BridgeDomain convert( + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.bridge.domains.BridgeDomain input) { final BridgeDomainBuilder builder = new BridgeDomainBuilder(); builder.setLearn(input.isLearn()); builder.setUnknownUnicastFlood(input.isUnknownUnicastFlood()); @@ -73,7 +74,7 @@ public class VppInitializer extends AbstractDataTreeConverter { builder.setName(input.getName()); setL2FibTable(builder, input.getL2FibTable()); return builder.build(); - }; + } private static void setL2FibTable(@Nonnull final BridgeDomainBuilder builder, @Nullable final L2FibTable l2FibTable) { @@ -81,11 +82,11 @@ public class VppInitializer extends AbstractDataTreeConverter { return; } final L2FibTableBuilder tableBuilder = new L2FibTableBuilder() - .setL2FibEntry( - l2FibTable.getL2FibEntry().stream() - // Convert operational object to config. VPP does not support setting BVI (see v3po.yang) - .map(oper -> new L2FibEntryBuilder(oper).setBridgedVirtualInterface(null).build()) - .collect(Collectors.toList())); + .setL2FibEntry( + l2FibTable.getL2FibEntry().stream() + // Convert operational object to config. VPP does not support setting BVI (see v3po.yang) + .map(oper -> new L2FibEntryBuilder(oper).setBridgedVirtualInterface(null).build()) + .collect(Collectors.toList())); builder.setL2FibTable(tableBuilder.build()); } -- cgit 1.2.3-korg