BUG-1199 : fixed NPE, when no LSPA attributes are advertised in Pcrpt. 65/8465/2
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 30 Jun 2014 19:22:34 +0000 (21:22 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 30 Jun 2014 19:41:14 +0000 (19:41 +0000)
Change-Id: I0cdf6f17b3aca95b6dfac482ba0c6c031e844696
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java

index 5d13f020b321f3dcc4f3bf5921885c1ae873312c..b4e8e75f2acd315333e6df190c8168b1ff6f7f41 100644 (file)
@@ -184,13 +184,15 @@ final class Stateful07TopologySessionListener extends AbstractTopologySessionLis
             if (tlvs != null && tlvs.getLspIdentifiers() != null) {
                 lspid = tlvs.getLspIdentifiers().getLspId();
             }
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
             if (report.getPath() != null) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
                 pb.fieldsFrom(report.getPath());
-                pb.addAugmentation(Path1.class, new Path1Builder().setLsp(report.getLsp()).build());
-                pb.setLspId(lspid);
-                rlb.setPath(Lists.newArrayList(pb.build()));
             }
+            // LSP is mandatory (if there is none, parser will throw an exception)
+            // this is to ensure a path will be created at any rate
+            pb.addAugmentation(Path1.class, new Path1Builder().setLsp(report.getLsp()).build());
+            pb.setLspId(lspid);
+            rlb.setPath(Lists.newArrayList(pb.build()));
             updateLsp(trans, plspid, name, rlb, solicited, lsp.isRemove());
             LOG.debug("LSP {} updated", lsp);
         }