summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-10-21 12:36:59 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-21 12:16:15 +0000
commitb17433b8e54489139c4cbcb91b82f375adfdf2de (patch)
treec1c3f7c330a85fcfc237d349c3b75dfba9496cc5
parent2e01a5cbb228684cdebf7f43806c68fe95dd0e79 (diff)
Fix ipv4 neighbor initialization (NPE)
Change-Id: I657db9617f3477201ccd6f1a8743b1843e99ba16 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
index cdf4bb306..791283bb8 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.fd.honeycomb.data.init.AbstractDataTreeConverter;
-import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -36,7 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1Builder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Neighbor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.Subnet;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder;
@@ -181,22 +179,23 @@ public class InterfacesInitializer extends AbstractDataTreeConverter<InterfacesS
final Ipv4 ipv4 = ietfIpAugmentation.getIpv4();
if (ipv4 != null) {
- final List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address>
- collect =
- ipv4.getAddress().stream()
- .map(
- address -> new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressBuilder()
- .setIp(address.getIp())
- .setSubnet(getSubnet(address))
- .build())
- .collect(Collectors.toList());
-
- final List<Neighbor> neighbors = ipv4.getNeighbor().stream()
- .map(neighbor -> new NeighborBuilder().setIp(neighbor.getIp())
- .setLinkLayerAddress(neighbor.getLinkLayerAddress()).build())
- .collect(Collectors.toList());
-
- augmentBuilder.setIpv4(new Ipv4Builder().setAddress(collect).setNeighbor(neighbors).build());
+ final Ipv4Builder ipv4Builder = new Ipv4Builder();
+ ipv4Builder.setAddress(
+ ipv4.getAddress().stream()
+ .map(address -> new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressBuilder()
+ .setIp(address.getIp())
+ .setSubnet(getSubnet(address))
+ .build())
+ .collect(Collectors.toList()));
+
+ if (ipv4.getNeighbor() != null) {
+ ipv4Builder.setNeighbor(ipv4.getNeighbor().stream()
+ .map(neighbor -> new NeighborBuilder().setIp(neighbor.getIp())
+ .setLinkLayerAddress(neighbor.getLinkLayerAddress()).build())
+ .collect(Collectors.toList()));
+ }
+
+ augmentBuilder.setIpv4(ipv4Builder.build());
}
builder.addAugmentation(Interface1.class, augmentBuilder.build());