summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-21 08:11:53 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-21 08:54:04 +0200
commitb998c9e140a4c3c39138a8e9c746be3d025dff8a (patch)
tree54ad0e20a6449de52be286258ed023f33600926d
parent5f1baedefebd2ee3c5003957a3441ca54ff3380e (diff)
Fix NPE in VppInitializer occuring when no BDs are configured
Change-Id: Iafebdc5dcc978313daf9818907fc27b2909ecc04 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java27
1 files changed, 14 insertions, 13 deletions
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<VppState, Vpp> {
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<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.vpp.state.bridge.domains.BridgeDomain, BridgeDomain>
- 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<VppState, Vpp> {
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<VppState, Vpp> {
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());
}